Errors of undefined reference to "..."



  • Hi All,

    I meet errors as following examples:
    /home/james/project/vis/src/funcs.cpp:58: undefined reference to `Geometry::Rotation<double, 3>::identity'
    or similar ones.

    All source files are in src folder.
    A strange thing is: 1) if I put .pro file in ./vis/src/ folder ( SOURCES and HEADERS folder in .pro are correct), these errors appear. 2) If I put .pro file in ./vis/ folder ( SOURCES and HEADERS folder in .pro are correct), everything works and has no errors. Could anyone give me any cues on how to solve this problem? Thank you very much!

    James



  • You can not move your *.pro file without editing it (the project files [sources, headerrs etc.] have relative pathes to the .pro file's location)

    Maybe it solves your problem



  • "or similar ones" - what does that mean? Just errors about undefined references or all errors about templates?



  • [quote author="remmos" date="1319595783"]You can not move your *.pro file without editing it (the project files [sources, headerrs etc.] have relative pathes to the .pro file's location)

    Maybe it solves your problem[/quote]

    I editted relative paths after moving it. It always has this problem. I read the created Makefile and found that "Rotation.cpp" does not in the SOURCES list. But it does in the list in .pro file.



  • [quote author="p-himik" date="1319604444"]"or similar ones" - what does that mean? Just errors about undefined references or all errors about templates?[/quote]

    it means the errors about undefined references on similar templates.



  • Probably you have to explicitly instantiate templates that give you errors.
    When you declare template in a header and place its implementation in .cpp file the compiler won't know for which template arguments it have to generate code.
    "Here":http://www.cplusplus.com/forum/articles/14272/ you can read more detailed info.



  • Mostly because you splitted between the template definition and declaration. C++ doesn't allow this, template function must be placed in header file.

    "C++ FAQ had it":http://www.parashift.com/c++-faq-lite/templates.html#faq-35.12


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.