Announcement

Collapse
No announcement yet.

Kdevelop error while building: 'undefined reference to' class

Collapse
This topic is closed.
X
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Kdevelop error while building: 'undefined reference to' class

    Installed Kdevelop 4.7.0 with apt.
    Didn't have any problems when there is only main.cpp.
    When I add class in separate file to project, I can't compile and I get 'undefined reference to' error message for class constructor or functions.
    I'm adding class with "Create from Template" wizard, all files are in project root, header files are properly included.
    I'm using make.


    When I add
    #include "SomeOtherSource.cpp"
    line at the end of main.cpp everything works, but that can't be the solution for this problem.
    I really like Kdevelop and wouldn't gladly switch to another IDE.
    Please help.

    #2
    'undefined reference to' is a linking error. Object code is probably not getting generated for your new file/class. You say you are using make, but I am guessing that you are using make through CMake? Do you have a CMakeLists.txt file in your project? You might have to add the new cpp file to the cmake target command. Post your cmakelists.txt file if you want.
    FKA: tanderson

    Comment


      #3
      Thank You for your answer blobfish. I love this community.

      I wasn't using CMake, but it seems that I will have to.
      Started new project, this time CMake, added class using wizard, checked includes - SAME thing.
      I had to manually add files to CMakeLists.txt
      This is strange behaviour, since when I wanted to rename class .h and .cpp CMake popped up offering
      me to rename them for me in CMakeLists.txt.
      If it can rename the entries, why can't it make them?

      Editing CMakeLists.txt is a workaround, but I expected more from IDE of this calibre.
      Do You think moving files to a subdirectory and then set a new include path in Project Configuration
      would be worth a shot?
      If not, we can mark this [SOLVED]...

      Comment


        #4
        Kdevelop adds files to my cmakelists file. Not sure why you are having problems. I wouldn't be changing my directory structure to work around an ide bug. The cmakelists files can become complicated and kdevelop doesn't put the file entries where I want. So I usually end up editing the file anyway.
        FKA: tanderson

        Comment


          #5
          The fact that Kdevelop adds files to cmakelists on Your sistem and advice to not change directories
          are good pointers for me.
          Editing cmakelists it is. Problem solved.
          My Kubuntu has a mind of his own, but I still love it.
          Thanks again.

          Comment


            #6
            Your welcome and happy coding.
            FKA: tanderson

            Comment

            Working...
            X