Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt Creator and other tools
  4. Undefined reference - again - discussion

Undefined reference - again - discussion

Scheduled Pinned Locked Moved Unsolved Qt Creator and other tools
18 Posts 4 Posters 1.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.
  • A Anonymous_Banned275

    @J-Hilk I am using changing the TEMPLATE as debugging tool.
    In my case just to make sure the code works / runs independent of library usage.
    I actually have two copies of the "problem
    " source code - one in subdirs project and one as an independent project.

    Mainly because when I change the template to app , I cannot "run" the problem code , the main subdirs project does not like "two" main apps.

    BTW

    I think the problem is in "mixing " include and actual link to the .so code - I am going to verify all of the next.

    A Offline
    A Offline
    Anonymous_Banned275
    wrote on last edited by
    #8

    @AnneRanch OK, here is complier / linker output AFTER the TEMPLATE = lib

    09:31:01: Running steps for project terminal...
    09:31:01: Starting: "/home/nov25-1/Qt/5.15.2/gcc_64/bin/qmake" /mnt/A_BT_DEC10/BT__PROGRAMS/A_MAR7_MAR15/A_BT_LIBRARY/CCC_SOURCE/TERMINAL_example_source/terminal/terminal.pro -spec linux-clang CONFIG+=debug CONFIG+=qml_debug
    Project MESSAGE: RESTOREd ALL resouces - DEBUG commneted out options resouces - same issue
    Project MESSAGE: Changed back to TEMPLATE = lib
    /mnt/A_BT_DEC10/BT__PROGRAMS/A_MAR7_MAR15/A_BT_LIBRARY/CCC_SOURCE/TERMINAL_example_source/terminal/terminal.pro:36: message(message) requires one argument.
    Project MESSAGE:
    09:31:01: The process "/home/nov25-1/Qt/5.15.2/gcc_64/bin/qmake" exited normally.

    09:31:01: Starting: "/usr/bin/make" -f /mnt/A_BT_DEC10/BT__PROGRAMS/A_MAR7_MAR15/A_BT_LIBRARY/CCC_SOURCE/TERMINAL_example_source/terminal/Makefile qmake_all
    make: Nothing to be done for 'qmake_all'.
    09:31:01: The process "/usr/bin/make" exited normally.

    09:31:01: Starting: "/usr/bin/make" -j4
    rm -f libterminal.so.1.0.0 libterminal.so libterminal.so.1 libterminal.so.1.0
    clang++ -ccc-gcc-name g++ -Wl,-rpath,/home/nov25-1/Qt/5.15.2/gcc_64/lib -shared -Wl,-soname,libterminal.so.1 -o libterminal.so.1.0.0 main.o settingsdialog.o console.o terminal_ORIGINAL_mainwindow.o qrc_terminal.o moc_settingsdialog.o moc_console.o moc_terminal_ORIGINAL_mainwindow.o /home/nov25-1/Qt/5.15.2/gcc_64/lib/libQt5Widgets.so

    /home/nov25-1/Qt/5.15.2/gcc_64/lib/libQt5Gui.so /home/nov25-1/Qt/5.15.2/gcc_64/lib/libQt5SerialPort.so /home/nov25-1/Qt/5.15.2/gcc_64/lib/libQt5Core.so -lGL -lpthread
    ln -s libterminal.so.1.0.0 libterminal.so
    ln -s libterminal.so.1.0.0 libterminal.so.1
    ln -s libterminal.so.1.0.0 libterminal.so.1.0
    09:31:03: The process "/usr/bin/make" exited normally.
    09:31:03: Elapsed time: 00:02.

    1.Does THIS output help me to ADD correct #include header to the "parent " class ?

    2.Does THIS output help me to ADD correct "library" to the "parent " class ?

    Using "Add library" option - internal or external or ...

    A 1 Reply Last reply
    0
    • A Anonymous_Banned275

      @AnneRanch OK, here is complier / linker output AFTER the TEMPLATE = lib

      09:31:01: Running steps for project terminal...
      09:31:01: Starting: "/home/nov25-1/Qt/5.15.2/gcc_64/bin/qmake" /mnt/A_BT_DEC10/BT__PROGRAMS/A_MAR7_MAR15/A_BT_LIBRARY/CCC_SOURCE/TERMINAL_example_source/terminal/terminal.pro -spec linux-clang CONFIG+=debug CONFIG+=qml_debug
      Project MESSAGE: RESTOREd ALL resouces - DEBUG commneted out options resouces - same issue
      Project MESSAGE: Changed back to TEMPLATE = lib
      /mnt/A_BT_DEC10/BT__PROGRAMS/A_MAR7_MAR15/A_BT_LIBRARY/CCC_SOURCE/TERMINAL_example_source/terminal/terminal.pro:36: message(message) requires one argument.
      Project MESSAGE:
      09:31:01: The process "/home/nov25-1/Qt/5.15.2/gcc_64/bin/qmake" exited normally.

      09:31:01: Starting: "/usr/bin/make" -f /mnt/A_BT_DEC10/BT__PROGRAMS/A_MAR7_MAR15/A_BT_LIBRARY/CCC_SOURCE/TERMINAL_example_source/terminal/Makefile qmake_all
      make: Nothing to be done for 'qmake_all'.
      09:31:01: The process "/usr/bin/make" exited normally.

      09:31:01: Starting: "/usr/bin/make" -j4
      rm -f libterminal.so.1.0.0 libterminal.so libterminal.so.1 libterminal.so.1.0
      clang++ -ccc-gcc-name g++ -Wl,-rpath,/home/nov25-1/Qt/5.15.2/gcc_64/lib -shared -Wl,-soname,libterminal.so.1 -o libterminal.so.1.0.0 main.o settingsdialog.o console.o terminal_ORIGINAL_mainwindow.o qrc_terminal.o moc_settingsdialog.o moc_console.o moc_terminal_ORIGINAL_mainwindow.o /home/nov25-1/Qt/5.15.2/gcc_64/lib/libQt5Widgets.so

      /home/nov25-1/Qt/5.15.2/gcc_64/lib/libQt5Gui.so /home/nov25-1/Qt/5.15.2/gcc_64/lib/libQt5SerialPort.so /home/nov25-1/Qt/5.15.2/gcc_64/lib/libQt5Core.so -lGL -lpthread
      ln -s libterminal.so.1.0.0 libterminal.so
      ln -s libterminal.so.1.0.0 libterminal.so.1
      ln -s libterminal.so.1.0.0 libterminal.so.1.0
      09:31:03: The process "/usr/bin/make" exited normally.
      09:31:03: Elapsed time: 00:02.

      1.Does THIS output help me to ADD correct #include header to the "parent " class ?

      2.Does THIS output help me to ADD correct "library" to the "parent " class ?

      Using "Add library" option - internal or external or ...

      A Offline
      A Offline
      Anonymous_Banned275
      wrote on last edited by
      #9

      @AnneRanch

      After
      changing the #include to

      #include < header file >

      adding library using "external " with full path

      I still get same , agree this is a linker, error pointing to here:

          // TEST_SUBPROJECT
          text = " TEMPORARY WINDOW TITLE CHANGED index 40 ...";
          TEST_PROJECT_MainWindow *pTEST_INDEX = new TEST_PROJECT_MainWindow();
          pTEST_INDEX->setWindowTitle(text);
          add_mdi_subwindow (pTEST_INDEX);
      
          // debug terminal issue
      
       This code fails but there is no compiler error indicated
      
      
          **terminal_ORIGINAL_MainWindow *pTERMINAL = new terminal_ORIGINAL_MainWindow();
          add_mdi_subwindow (pTERMINAL);**
      
       This code fails but there is no compiler indicated
      
      JonBJ 1 Reply Last reply
      0
      • A Anonymous_Banned275

        @AnneRanch

        After
        changing the #include to

        #include < header file >

        adding library using "external " with full path

        I still get same , agree this is a linker, error pointing to here:

            // TEST_SUBPROJECT
            text = " TEMPORARY WINDOW TITLE CHANGED index 40 ...";
            TEST_PROJECT_MainWindow *pTEST_INDEX = new TEST_PROJECT_MainWindow();
            pTEST_INDEX->setWindowTitle(text);
            add_mdi_subwindow (pTEST_INDEX);
        
            // debug terminal issue
        
         This code fails but there is no compiler error indicated
        
        
            **terminal_ORIGINAL_MainWindow *pTERMINAL = new terminal_ORIGINAL_MainWindow();
            add_mdi_subwindow (pTERMINAL);**
        
         This code fails but there is no compiler indicated
        
        JonBJ Offline
        JonBJ Offline
        JonB
        wrote on last edited by JonB
        #10

        @AnneRanch said in Undefined reference - again - discussion:

        This code fails but there is no compiler error indicated

        That is because it is a linker error. You told the compiler that there is a terminal_ORIGINAL_MainWindow class in another file, but you did not link with terminal_ORIGINAL_MainWindow.o , which you need to do as it has the class code, so the linker could not succeed.

        If you had not #included the terminal_ORIGINAL_MainWindow.h file THAT would have given a compilation error on the new terminal_ORIGINAL_MainWindow() line. But including that allows it to compile, and says the terminal_ORIGINAL_MainWindow.o object file will be provided at link time. But, for whatever reason, it is not when you get your error.

        That is what the Undefined reference error message from linker (ld) indicates each time.

        A 2 Replies Last reply
        0
        • JonBJ JonB

          @AnneRanch said in Undefined reference - again - discussion:

          This code fails but there is no compiler error indicated

          That is because it is a linker error. You told the compiler that there is a terminal_ORIGINAL_MainWindow class in another file, but you did not link with terminal_ORIGINAL_MainWindow.o , which you need to do as it has the class code, so the linker could not succeed.

          If you had not #included the terminal_ORIGINAL_MainWindow.h file THAT would have given a compilation error on the new terminal_ORIGINAL_MainWindow() line. But including that allows it to compile, and says the terminal_ORIGINAL_MainWindow.o object file will be provided at link time. But, for whatever reason, it is not when you get your error.

          That is what the Undefined reference error message from linker (ld) indicates each time.

          A Offline
          A Offline
          Anonymous_Banned275
          wrote on last edited by
          #11
          This post is deleted!
          1 Reply Last reply
          0
          • A Offline
            A Offline
            Anonymous_Banned275
            wrote on last edited by Anonymous_Banned275
            #12

            UPDATE

            I have given up trying to physically find the "linker" problem.
            I am trying a DIFFERENT way to resolve this AND could use some help.

            I now have TWO "subdirs" projects - my main one , the one which refuses to work , and working "helper project".

            The "helper project" works as expected - here is the result:

            41b23c80-a94c-42ef-8716-3a4b2602ab9b-image.png

            ![2c014c03-91ca-4ba5-ae24-cf8f36e7d9c3-image.png](https://ddgobkiprc33d.cloudfront.net/e8891de0-f237-4934-894d-ed0fc54abae2.png

            As "subdirs" , the "helper project" has main .pro and terminal .pro.

            I repeat - the "terminal" helper project works BY ITSELF as expected.

            I have successfully added the "helper project " to my main project. - "TEST_MAIN_SUBPROJECT "

            Here is the picture of ALL .pro files in it:

            f34e3ce7-7b94-40a5-b026-07f4a6c6004a-image.png

            HERE IS WHAT I NEED HELP WITH
            Currently the TEST_MAIN_SUBPROJECT runs
            TERMINAL_SUBDIRS_PROJECT "MAIN_PROJECT" - as posted at the start of this post.

            I need to SWITCH it to run

            A_Mar7_MAR17.pro

            the original , faulty project , which refuses to link with "terminal".

            ca6a2994-e8c5-4934-b5a7-21e0adafc493-image.png

            I am hoping that I can then use the working

            TERMINAL_SUBDIRS_PROJECT and its working "terminal".

            My main, so far faulty , project MaiN WINDOW IS "mdi.pro".
            I would prefer to use "mdi.pro"
            , but if it will work I could run the

            TERMINAL_SUBDIRS_PROJECT "MAIN_PROJECT"(,pro) main window" with
            A_Mar7_MAR17.pro as child.

            I do realize this approach is convoluted, but my main goal is is to link "TEST_MAIN_SUBPROJECT " with "terminal" irregardless how many parent - child levels it takes.

            THANKS

            A 1 Reply Last reply
            0
            • A Anonymous_Banned275

              UPDATE

              I have given up trying to physically find the "linker" problem.
              I am trying a DIFFERENT way to resolve this AND could use some help.

              I now have TWO "subdirs" projects - my main one , the one which refuses to work , and working "helper project".

              The "helper project" works as expected - here is the result:

              41b23c80-a94c-42ef-8716-3a4b2602ab9b-image.png

              ![2c014c03-91ca-4ba5-ae24-cf8f36e7d9c3-image.png](https://ddgobkiprc33d.cloudfront.net/e8891de0-f237-4934-894d-ed0fc54abae2.png

              As "subdirs" , the "helper project" has main .pro and terminal .pro.

              I repeat - the "terminal" helper project works BY ITSELF as expected.

              I have successfully added the "helper project " to my main project. - "TEST_MAIN_SUBPROJECT "

              Here is the picture of ALL .pro files in it:

              f34e3ce7-7b94-40a5-b026-07f4a6c6004a-image.png

              HERE IS WHAT I NEED HELP WITH
              Currently the TEST_MAIN_SUBPROJECT runs
              TERMINAL_SUBDIRS_PROJECT "MAIN_PROJECT" - as posted at the start of this post.

              I need to SWITCH it to run

              A_Mar7_MAR17.pro

              the original , faulty project , which refuses to link with "terminal".

              ca6a2994-e8c5-4934-b5a7-21e0adafc493-image.png

              I am hoping that I can then use the working

              TERMINAL_SUBDIRS_PROJECT and its working "terminal".

              My main, so far faulty , project MaiN WINDOW IS "mdi.pro".
              I would prefer to use "mdi.pro"
              , but if it will work I could run the

              TERMINAL_SUBDIRS_PROJECT "MAIN_PROJECT"(,pro) main window" with
              A_Mar7_MAR17.pro as child.

              I do realize this approach is convoluted, but my main goal is is to link "TEST_MAIN_SUBPROJECT " with "terminal" irregardless how many parent - child levels it takes.

              THANKS

              A Offline
              A Offline
              Anonymous_Banned275
              wrote on last edited by
              #13

              @AnneRanch UPDATE

              Question
              what configures the Qt to run TEST_MAIN_SUBPROJECTpro ?

              09:12:11: Running steps for project TEST_MAIN_SUBPROJECT...
              09:12:11: Starting: "/home/nov25-1/Qt/5.15.2/gcc_64/bin/qmake" /mnt/A_BT_DEC10/BT__PROGRAMS/A_APR/A_APR6_MAR7_MAR19_CLEAN/A_BT_LIBRARY/CCC_SOURCE/TEST_MAIN_SUBPROJECT_PROJECT/TEST_MAIN_SUBPROJECT/TEST_MAIN_SUBPROJECT.pro -spec linux-clang CONFIG+=debug CONFIG+=qml_debug CONFIG+=force_debug_info CONFIG+=separate_debug_info
              Project MESSAGE:
              Project MESSAGE: run TEST_MAIN_SUBPROJECT.pro
              Project MESSAGE:

              it is LAST .pro in the project

              10fddb64-c7e9-4c6c-9b4c-8f4ba1651412-image.png

              J.HilkJ 1 Reply Last reply
              0
              • A Anonymous_Banned275

                @AnneRanch UPDATE

                Question
                what configures the Qt to run TEST_MAIN_SUBPROJECTpro ?

                09:12:11: Running steps for project TEST_MAIN_SUBPROJECT...
                09:12:11: Starting: "/home/nov25-1/Qt/5.15.2/gcc_64/bin/qmake" /mnt/A_BT_DEC10/BT__PROGRAMS/A_APR/A_APR6_MAR7_MAR19_CLEAN/A_BT_LIBRARY/CCC_SOURCE/TEST_MAIN_SUBPROJECT_PROJECT/TEST_MAIN_SUBPROJECT/TEST_MAIN_SUBPROJECT.pro -spec linux-clang CONFIG+=debug CONFIG+=qml_debug CONFIG+=force_debug_info CONFIG+=separate_debug_info
                Project MESSAGE:
                Project MESSAGE: run TEST_MAIN_SUBPROJECT.pro
                Project MESSAGE:

                it is LAST .pro in the project

                10fddb64-c7e9-4c6c-9b4c-8f4ba1651412-image.png

                J.HilkJ Offline
                J.HilkJ Offline
                J.Hilk
                Moderators
                wrote on last edited by
                #14

                @AnneRanch said in Undefined reference - again - discussion:

                what configures the Qt to run TEST_MAIN_SUBPROJECTpro ?

                when your project creates multiple executables that could potentially be executed. You can specify inside the project tab under "run settings" which executable is supposed to be run.

                afcc0a39-dd12-499b-bab1-cdca662becae-image.png


                Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


                Q: What's that?
                A: It's blue light.
                Q: What does it do?
                A: It turns blue.

                A 1 Reply Last reply
                1
                • J.HilkJ J.Hilk

                  @AnneRanch said in Undefined reference - again - discussion:

                  what configures the Qt to run TEST_MAIN_SUBPROJECTpro ?

                  when your project creates multiple executables that could potentially be executed. You can specify inside the project tab under "run settings" which executable is supposed to be run.

                  afcc0a39-dd12-499b-bab1-cdca662becae-image.png

                  A Offline
                  A Offline
                  Anonymous_Banned275
                  wrote on last edited by
                  #15

                  @J-Hilk f95763d0-7eba-4935-ad41-79232048202a-image.png

                  OK , I got this , BUT
                  it looks as there is no "pull down " box...

                  Not sure I want to do this manually.

                  JonBJ 1 Reply Last reply
                  0
                  • A Anonymous_Banned275

                    @J-Hilk f95763d0-7eba-4935-ad41-79232048202a-image.png

                    OK , I got this , BUT
                    it looks as there is no "pull down " box...

                    Not sure I want to do this manually.

                    JonBJ Offline
                    JonBJ Offline
                    JonB
                    wrote on last edited by JonB
                    #16

                    @AnneRanch
                    You are looking at Build Settings. @J-Hilk showed Run Settings

                    You can specify inside the project tab under "run settings" which executable is supposed to be run.

                    1 Reply Last reply
                    1
                    • A Offline
                      A Offline
                      Anonymous_Banned275
                      wrote on last edited by Anonymous_Banned275
                      #17

                      @JonB Unfortunately 'run setting" does not let select .pro but sudirs project executable.
                      That does not help to bypass the terminal problem.
                      If I select modify and select "mdi" it actually runs the "mdi" BEFORE the modification.
                      The editor shows errors , it should, and it should not run.

                      1 Reply Last reply
                      0
                      • JonBJ JonB referenced this topic on
                      • JonBJ JonB

                        @AnneRanch said in Undefined reference - again - discussion:

                        This code fails but there is no compiler error indicated

                        That is because it is a linker error. You told the compiler that there is a terminal_ORIGINAL_MainWindow class in another file, but you did not link with terminal_ORIGINAL_MainWindow.o , which you need to do as it has the class code, so the linker could not succeed.

                        If you had not #included the terminal_ORIGINAL_MainWindow.h file THAT would have given a compilation error on the new terminal_ORIGINAL_MainWindow() line. But including that allows it to compile, and says the terminal_ORIGINAL_MainWindow.o object file will be provided at link time. But, for whatever reason, it is not when you get your error.

                        That is what the Undefined reference error message from linker (ld) indicates each time.

                        A Offline
                        A Offline
                        Anonymous_Banned275
                        wrote on last edited by
                        #18

                        @JonB OK, back to terminology...
                        I use "Add library" to add it to the subproject / object who needs it...
                        I let Qt to select "internal" library ....by project name - AKA "terminal"
                        From there it is Qt who actually adds stuff - mostly to .pro file.

                        I have to add required headers...
                        editor and compiler passes the headers as valid

                        Then I usually run "Clear" and "Rebuild".
                        That is it...

                        I do not see the references to library.o AND library.so until the complier / linker is done.

                        The linker error is actually very last few lies of the "Rebuild" process.

                        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