2

Having trouble compiling my .cpp files. Compiler gave me a lot of error lines, a snippet of it is shown below. (not all shown as there's a lot of error lines just like these)

What kind of error this may be referring to?

/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':

Please advice.

M.TwT
  • 73
  • 7
  • 3
    This is a linker error, not a language error. `operator==` is declared but not found at the linking stage. – alfC Aug 26 '18 at 06:12
  • You should show some [MCVE] or at least your entire compilation commands. Perhaps some `*.o` object file is missing at link step – Basile Starynkevitch Aug 26 '18 at 06:23

1 Answers1

2

First of all, I'll advise you to read this, and try follow it as much as possible. In particular regarding this post, read here.

Seems like you're using a std::vector<Point2D> (and one for Point3d too) but the linker (not the compiler -- your code compiled without errors) cannot resolve (i.e. find) your definition for operator == of this type (being Point2d).

To solve this linker error, better read and follow this: What is an undefined reference/unresolved external symbol error and how do I fix it? .

Geezer
  • 5,600
  • 18
  • 31
  • The first two looks would be better as a comment and the last link would be better to flag this question as a duplicate – Alan Birtles Aug 26 '18 at 07:04
  • @AlanBirtles Thanks for the feedback! I'll definitely take that into consideration. – Geezer Aug 26 '18 at 07:21
  • @AlanBirtles my 2 cents on this would be that the question is neither titled or asked as the one I put for further reference. So a duplicate it isn't. At least if the predicate 'duplicate' means that the question and its duplicant need to "look" the same from the OP's perspective -- as for one this OP isn't even aware of this being a linker error, thus the question here in this post isn't the same one as the one linked. – Geezer Aug 26 '18 at 07:27
  • @AlanBirtles Stricly referring her/him to the other question will be meaningless for him without the extra information that what he is encountering is in fact a linker error. – Geezer Aug 26 '18 at 07:28
  • @AlanBirtles I guess you find it right to downvote -- but if this is a good answer for *his question* -- not found elsewhere on OS -- than you're punishing this answer not for being a bad one. Pretty sure this is not what the voting mechanism is for. – Geezer Aug 26 '18 at 07:31