【发布时间】:2018-08-26 06:10:28
【问题描述】:
编译我的 .cpp 文件时遇到问题。编译器给了我很多错误行,它的一个 sn-p 如下所示。 (没有全部显示,因为有很多像这样的错误行)
这可能指的是哪种错误?
/tmp/ccl9wLjI.o: In function `bool __gnu_cxx::__ops::_Iter_equal_to_iter::operator()<__gnu_cxx::__normal_iterator<Point2D*, std::vector<Point2D, std::allocator<Point2D> > >, __gnu_cxx::__normal_iterator<Point2D*, std::vector<Point2D, std::allocator<Point2D> > > >(__gnu_cxx::__normal_iterator<Point2D*, std::vector<Point2D, std::allocator<Point2D> > >, __gnu_cxx::__normal_iterator<Point2D*, std::vector<Point2D, std::allocator<Point2D> > >) const':
Main.cpp:(.text._ZNK9__gnu_cxx5__ops19_Iter_equal_to_iterclINS_17__normal_iteratorIP7Point2DSt6vectorIS4_SaIS4_EEEES9_EEbT_T0_[_ZNK9__gnu_cxx5__ops19_Iter_equal_to_iterclINS_17__normal_iteratorIP7Point2DSt6vectorIS4_SaIS4_EEEES9_EEbT_T0_]+0x2d): undefined reference to `operator==(Point2D&, Point2D&)'
/tmp/ccl9wLjI.o: In function `bool __gnu_cxx::__ops::_Iter_equal_to_iter::operator()<__gnu_cxx::__normal_iterator<Point3D*, std::vector<Point3D, std::allocator<Point3D> > >, __gnu_cxx::__normal_iterator<Point3D*, std::vector<Point3D, std::allocator<Point3D> > > >(__gnu_cxx::__normal_iterator<Point3D*, std::vector<Point3D, std::allocator<Point3D> > >, __gnu_cxx::__normal_iterator<Point3D*, std::vector<Point3D, std::allocator<Point3D> > >) const':
请指教。
【问题讨论】:
-
这是链接器错误,而不是语言错误。
operator==已声明但在链接阶段未找到。 -
你应该显示一些minimal reproducible example 或者至少你的整个编译命令。链接步骤中可能缺少一些
*.o目标文件
标签: c++ compiler-errors compilation