Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Errors of undefined reference to "..."

Errors of undefined reference to "..."

Scheduled Pinned Locked Moved General and Desktop
7 Posts 4 Posters 3.4k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • J Offline
    J Offline
    James
    wrote on last edited by
    #1

    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

    1 Reply Last reply
    0
    • R Offline
      R Offline
      remmos
      wrote on last edited by
      #2

      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

      1 Reply Last reply
      0
      • P Offline
        P Offline
        p-himik
        wrote on last edited by
        #3

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

        1 Reply Last reply
        0
        • J Offline
          J Offline
          James
          wrote on last edited by
          #4

          [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.

          1 Reply Last reply
          0
          • J Offline
            J Offline
            James
            wrote on last edited by
            #5

            [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.

            1 Reply Last reply
            0
            • P Offline
              P Offline
              p-himik
              wrote on last edited by
              #6

              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.

              1 Reply Last reply
              0
              • A Offline
                A Offline
                ardhitama
                wrote on last edited by
                #7

                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

                Love automagically stuffs

                1 Reply Last reply
                0

                • Login

                • Login or register to search.
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • Users
                • Groups
                • Search
                • Get Qt Extensions
                • Unsolved