无法编译我的.cpp文件。编译器给了我很多错误,下面是其中的摘要。 (并非全部显示出来,因为有很多这样的错误行)
这可能是指哪种错误?
/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':
请咨询。
答案 0 :(得分:2)
首先,我建议您使用read this,并尝试尽可能多地遵循它。特别是关于此帖子,read here。
好像您使用的是std::vector<Point2D>
(还有一个用于Point3d
),但使用 linker (不是 compiler )-正确编译的代码)无法解析(即找到)此类型(==
)运算符Point2d
的定义。
要解决此链接器错误,请更好地阅读并遵循以下说明:What is an undefined reference/unresolved external symbol error and how do I fix it? 。