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. how to fix linker error in eclipse on linux
QtWS25 Last Chance

how to fix linker error in eclipse on linux

Scheduled Pinned Locked Moved Solved General and Desktop
58 Posts 3 Posters 10.7k 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.
  • M Offline
    M Offline
    micha_eleric
    wrote on 23 Feb 2022, 00:59 last edited by micha_eleric
    #30

    under Properties->C/C++ Build->Settings->Tool Settings->GCC C++ Linker->Libraries->Libraries (-l) /usr/lib/x86_64-linux-gnu
    /usr/bin/ld: cannot find -l/usr/lib/x86_64-linux-gnu
    under Properties->C/C++ Build->Settings->Tool Settings->GCC C++ Linker->Libraries->Libraries (-l) /usr/lib/x86_64-linux-gnu/qt5
    /usr/bin/ld: cannot find -l/usr/lib/x86_64-linux-gnu/qt5

    both have libraries, but no clue if i have to add a specific file, or just the dir it is in

    under Properties->C/C++ Build->Settings->Tool Settings->GCC C++ Linker->Libraries->Libraries (-l) /usr/lib/x86_64-linux-gnu/libQtCore
    /usr/bin/ld: cannot find -l/usr/lib/x86_64-linux-gnu/libQtCore
    under Properties->C/C++ Build->Settings->Tool Settings->GCC C++ Linker->Libraries->Libraries (-l) /usr/lib/x86_64-linux-gnu/libQtCore.so
    /usr/bin/ld: cannot find -l/usr/lib/x86_64-linux-gnu/libQtCore.so

    it can not find a library, so i have to be doing something wrong

    J 1 Reply Last reply 23 Feb 2022, 05:13
    0
    • M Offline
      M Offline
      micha_eleric
      wrote on 23 Feb 2022, 04:52 last edited by
      #31

      michaeleric@michaeleric-C7B250-CB-ML:~$ sudo find / -name '*MainWindow *'
      [sudo] password for michaeleric:
      /home/michaeleric/eclipse-workspace/GUI/CUi_MainWindow.h
      find: ‘/run/user/1000/doc’: Permission denied
      /usr/share/doc/HTML/ca/spectacle/MainWindow.png
      /usr/share/doc/HTML/uk/spectacle/MainWindow.png
      /usr/share/doc/HTML/en/spectacle/MainWindow.png
      /usr/include/qt4/Qt3Support/Q3MainWindow
      /usr/include/qt4/QtGui/QMainWindow
      /usr/include/x86_64-linux-gnu/qt5/QtWidgets/QMainWindow
      michaeleric@michaeleric-C7B250-CB-ML:~$

      there are no .h files for QMainWindow under Qt5 anywhere, thus why i was using Qt4, and thought Qt4 was installed.
      error is about undefined reference to `QMainWindow:
      i am looking around for a needle in a haystack, but dont know what the needle looks like, nor which haystack

      1 Reply Last reply
      0
      • M micha_eleric
        23 Feb 2022, 00:59

        under Properties->C/C++ Build->Settings->Tool Settings->GCC C++ Linker->Libraries->Libraries (-l) /usr/lib/x86_64-linux-gnu
        /usr/bin/ld: cannot find -l/usr/lib/x86_64-linux-gnu
        under Properties->C/C++ Build->Settings->Tool Settings->GCC C++ Linker->Libraries->Libraries (-l) /usr/lib/x86_64-linux-gnu/qt5
        /usr/bin/ld: cannot find -l/usr/lib/x86_64-linux-gnu/qt5

        both have libraries, but no clue if i have to add a specific file, or just the dir it is in

        under Properties->C/C++ Build->Settings->Tool Settings->GCC C++ Linker->Libraries->Libraries (-l) /usr/lib/x86_64-linux-gnu/libQtCore
        /usr/bin/ld: cannot find -l/usr/lib/x86_64-linux-gnu/libQtCore
        under Properties->C/C++ Build->Settings->Tool Settings->GCC C++ Linker->Libraries->Libraries (-l) /usr/lib/x86_64-linux-gnu/libQtCore.so
        /usr/bin/ld: cannot find -l/usr/lib/x86_64-linux-gnu/libQtCore.so

        it can not find a library, so i have to be doing something wrong

        J Offline
        J Offline
        jsulm
        Lifetime Qt Champion
        wrote on 23 Feb 2022, 05:13 last edited by
        #32

        @micha_eleric said in how to fix linker error in eclipse on linux:

        it can not find a library

        Please post the error message.

        "there are no .h files for QMainWindow under Qt5 anywhere" - of course there is if you installed qtwidgets module, see https://doc.qt.io/qt-5/qmainwindow.html

        I'm wondering: why don't you use a proper build system like qmake or CMake instead hacking around with manual settings?

        https://forum.qt.io/topic/113070/qt-code-of-conduct

        M 3 Replies Last reply 23 Feb 2022, 05:27
        0
        • J jsulm
          23 Feb 2022, 05:13

          @micha_eleric said in how to fix linker error in eclipse on linux:

          it can not find a library

          Please post the error message.

          "there are no .h files for QMainWindow under Qt5 anywhere" - of course there is if you installed qtwidgets module, see https://doc.qt.io/qt-5/qmainwindow.html

          I'm wondering: why don't you use a proper build system like qmake or CMake instead hacking around with manual settings?

          M Offline
          M Offline
          micha_eleric
          wrote on 23 Feb 2022, 05:27 last edited by
          #33

          @jsulm

          using eclipse on linux
          error, i am mostly sure is an eclipse issue, and not a programming issue.

          g++ -L/usr/include/qt4 -L/usr/include/qt4/QtSerialPort -L/usr/include/qt4/QtGui -o "GUI2" ./src/CGUI.o ./src/Main.o
          /usr/bin/ld: ./src/CGUI.o: in function CGUI::CGUI()': /home/michaeleric/eclipse-workspace/GUI2/Debug/../src/CGUI.cpp:10: undefined reference toQMainWindow::QMainWindow(QWidget*, QFlagsQt::WindowType)'
          /usr/bin/ld: /home/michaeleric/eclipse-workspace/GUI2/Debug/../src/CGUI.cpp:10: undefined reference to vtable for CGUI' /usr/bin/ld: /home/michaeleric/eclipse-workspace/GUI2/Debug/../src/CGUI.cpp:10: undefined reference tovtable for CGUI'
          /usr/bin/ld: ./src/CGUI.o: in function CGUI::~CGUI()': /home/michaeleric/eclipse-workspace/GUI2/Debug/../src/CGUI.cpp:15: undefined reference tovtable for CGUI'
          /usr/bin/ld: /home/michaeleric/eclipse-workspace/GUI2/Debug/../src/CGUI.cpp:15: undefined reference to vtable for CGUI' /usr/bin/ld: /home/michaeleric/eclipse-workspace/GUI2/Debug/../src/CGUI.cpp:15: undefined reference toQMainWindow::~QMainWindow()'
          /usr/bin/ld: ./src/Main.o: in function main': /home/michaeleric/eclipse-workspace/GUI2/Debug/../src/Main.cpp:14: undefined reference toQApplication::QApplication(int&, char**, int)'
          /usr/bin/ld: /home/michaeleric/eclipse-workspace/GUI2/Debug/../src/Main.cpp:17: undefined reference to QApplication::exec()' /usr/bin/ld: /home/michaeleric/eclipse-workspace/GUI2/Debug/../src/Main.cpp:14: undefined reference toQApplication::~QApplication()'
          /usr/bin/ld: /home/michaeleric/eclipse-workspace/GUI2/Debug/../src/Main.cpp:14: undefined reference to `QApplication::~QApplication()'
          collect2: error: ld returned 1 exit status
          make: *** [makefile:47: GUI2] Error 1

          based on https://forum.qt.io/topic/101400/qt-with-eclipse-c/5 , i added QtCore and QtWidgets, even though there were no errors with #include<>. same errors from compile.

          https://stackoverflow.com/questions/6478317/eclipse-undefined-reference says it is a linker error

          under Properties->C/C++ Build->Settings->Tool Settings->GCC C++ Linker->command: g++

          under Properties->C/C++ Build->Settings->Tool Settings->GCC C++ Linker->Libraries->Libraries (-l) [nothing]

          under Properties->C/C++ Build->Settings->Tool Settings->GCC C++ Linker->Libraries->Libraries search path (-L) /usr/include/qt4 /usr/include/qt4/QtWidgets /usr/include/qt4/QtCore /usr/include/qt4/QtSerialPort /usr/include/qt4/QtGui

          under Properties->C/C++ Build->Settings->Tool Settings->GCC C++ Linker->Miscellaneous->Linker flags [nothing]

          under Properties->C/C++ Build->Settings->Tool Settings->GCC C++ Linker->Miscellaneous->Other options (-Xlinker [option]) [nothing]

          under Properties->C/C++ Build->Settings->Tool Settings->GCC C++ Linker->Miscellaneous->Other objects [nothing]

          under Properties->C/C++ Build->Settings->Tool Settings->GCC C++ Linker->Shared Library Settings [nothing][nothing][nothing][nothing]

          what is suppose to be added, and where?

          if:
          under Properties->C/C++ Build->Settings->Tool Settings->GCC C++ Linker->Libraries->Libraries (-l) /usr/include/qt4/QtGui
          error:
          /usr/bin/ld: cannot find -l/usr/include/qt4/QtGui

          if:
          under Properties->C/C++ Build->Settings->Tool Settings->GCC C++ Linker->Miscellaneous->Other options (-Xlinker [option]) /usr/include/qt4/QtGui
          error:
          /usr/bin/ld: cannot find /usr/include/qt4/QtGui: file format not recognized

          if:
          under Properties->C/C++ Build->Settings->Tool Settings->GCC C++ Linker->Miscellaneous->Other objects /usr/include/qt4/QtGui
          error:
          /usr/bin/ld: cannot find /usr/include/qt4/QtGui: file format not recognized

          if it is a virtual function that has to be defined, then what would it be, other than constructor/destructor?

          J 1 Reply Last reply 23 Feb 2022, 05:32
          0
          • J jsulm
            23 Feb 2022, 05:13

            @micha_eleric said in how to fix linker error in eclipse on linux:

            it can not find a library

            Please post the error message.

            "there are no .h files for QMainWindow under Qt5 anywhere" - of course there is if you installed qtwidgets module, see https://doc.qt.io/qt-5/qmainwindow.html

            I'm wondering: why don't you use a proper build system like qmake or CMake instead hacking around with manual settings?

            M Offline
            M Offline
            micha_eleric
            wrote on 23 Feb 2022, 05:29 last edited by
            #34

            @jsulm only "hacking" i am doing, is trying to find the path to the lib

            1 Reply Last reply
            0
            • M micha_eleric
              23 Feb 2022, 05:27

              @jsulm

              using eclipse on linux
              error, i am mostly sure is an eclipse issue, and not a programming issue.

              g++ -L/usr/include/qt4 -L/usr/include/qt4/QtSerialPort -L/usr/include/qt4/QtGui -o "GUI2" ./src/CGUI.o ./src/Main.o
              /usr/bin/ld: ./src/CGUI.o: in function CGUI::CGUI()': /home/michaeleric/eclipse-workspace/GUI2/Debug/../src/CGUI.cpp:10: undefined reference toQMainWindow::QMainWindow(QWidget*, QFlagsQt::WindowType)'
              /usr/bin/ld: /home/michaeleric/eclipse-workspace/GUI2/Debug/../src/CGUI.cpp:10: undefined reference to vtable for CGUI' /usr/bin/ld: /home/michaeleric/eclipse-workspace/GUI2/Debug/../src/CGUI.cpp:10: undefined reference tovtable for CGUI'
              /usr/bin/ld: ./src/CGUI.o: in function CGUI::~CGUI()': /home/michaeleric/eclipse-workspace/GUI2/Debug/../src/CGUI.cpp:15: undefined reference tovtable for CGUI'
              /usr/bin/ld: /home/michaeleric/eclipse-workspace/GUI2/Debug/../src/CGUI.cpp:15: undefined reference to vtable for CGUI' /usr/bin/ld: /home/michaeleric/eclipse-workspace/GUI2/Debug/../src/CGUI.cpp:15: undefined reference toQMainWindow::~QMainWindow()'
              /usr/bin/ld: ./src/Main.o: in function main': /home/michaeleric/eclipse-workspace/GUI2/Debug/../src/Main.cpp:14: undefined reference toQApplication::QApplication(int&, char**, int)'
              /usr/bin/ld: /home/michaeleric/eclipse-workspace/GUI2/Debug/../src/Main.cpp:17: undefined reference to QApplication::exec()' /usr/bin/ld: /home/michaeleric/eclipse-workspace/GUI2/Debug/../src/Main.cpp:14: undefined reference toQApplication::~QApplication()'
              /usr/bin/ld: /home/michaeleric/eclipse-workspace/GUI2/Debug/../src/Main.cpp:14: undefined reference to `QApplication::~QApplication()'
              collect2: error: ld returned 1 exit status
              make: *** [makefile:47: GUI2] Error 1

              based on https://forum.qt.io/topic/101400/qt-with-eclipse-c/5 , i added QtCore and QtWidgets, even though there were no errors with #include<>. same errors from compile.

              https://stackoverflow.com/questions/6478317/eclipse-undefined-reference says it is a linker error

              under Properties->C/C++ Build->Settings->Tool Settings->GCC C++ Linker->command: g++

              under Properties->C/C++ Build->Settings->Tool Settings->GCC C++ Linker->Libraries->Libraries (-l) [nothing]

              under Properties->C/C++ Build->Settings->Tool Settings->GCC C++ Linker->Libraries->Libraries search path (-L) /usr/include/qt4 /usr/include/qt4/QtWidgets /usr/include/qt4/QtCore /usr/include/qt4/QtSerialPort /usr/include/qt4/QtGui

              under Properties->C/C++ Build->Settings->Tool Settings->GCC C++ Linker->Miscellaneous->Linker flags [nothing]

              under Properties->C/C++ Build->Settings->Tool Settings->GCC C++ Linker->Miscellaneous->Other options (-Xlinker [option]) [nothing]

              under Properties->C/C++ Build->Settings->Tool Settings->GCC C++ Linker->Miscellaneous->Other objects [nothing]

              under Properties->C/C++ Build->Settings->Tool Settings->GCC C++ Linker->Shared Library Settings [nothing][nothing][nothing][nothing]

              what is suppose to be added, and where?

              if:
              under Properties->C/C++ Build->Settings->Tool Settings->GCC C++ Linker->Libraries->Libraries (-l) /usr/include/qt4/QtGui
              error:
              /usr/bin/ld: cannot find -l/usr/include/qt4/QtGui

              if:
              under Properties->C/C++ Build->Settings->Tool Settings->GCC C++ Linker->Miscellaneous->Other options (-Xlinker [option]) /usr/include/qt4/QtGui
              error:
              /usr/bin/ld: cannot find /usr/include/qt4/QtGui: file format not recognized

              if:
              under Properties->C/C++ Build->Settings->Tool Settings->GCC C++ Linker->Miscellaneous->Other objects /usr/include/qt4/QtGui
              error:
              /usr/bin/ld: cannot find /usr/include/qt4/QtGui: file format not recognized

              if it is a virtual function that has to be defined, then what would it be, other than constructor/destructor?

              J Offline
              J Offline
              jsulm
              Lifetime Qt Champion
              wrote on 23 Feb 2022, 05:32 last edited by jsulm
              #35

              @micha_eleric said in how to fix linker error in eclipse on linux:

              under Properties->C/C++ Build->Settings->Tool Settings->GCC C++ Linker->Libraries->Libraries search path (-L) /usr/include/qt4 /usr/include/qt4/QtWidgets

              You are again adding include folder as library folder, why?! I already told you before that you need to set folder containing the libraries and we even figured out what it is (/lib/x86_64-linux-gnu). So, please set proper library folder...

              https://forum.qt.io/topic/113070/qt-code-of-conduct

              1 Reply Last reply
              0
              • J jsulm
                23 Feb 2022, 05:13

                @micha_eleric said in how to fix linker error in eclipse on linux:

                it can not find a library

                Please post the error message.

                "there are no .h files for QMainWindow under Qt5 anywhere" - of course there is if you installed qtwidgets module, see https://doc.qt.io/qt-5/qmainwindow.html

                I'm wondering: why don't you use a proper build system like qmake or CMake instead hacking around with manual settings?

                M Offline
                M Offline
                micha_eleric
                wrote on 23 Feb 2022, 05:34 last edited by
                #36

                @jsulm

                "there are no .h files for QMainWindow under Qt5 anywhere" - of course there is if you installed qtwidgets module, see https://doc.qt.io/qt-5/qmainwindow.html

                not an install link

                J 1 Reply Last reply 23 Feb 2022, 05:52
                0
                • M micha_eleric
                  23 Feb 2022, 05:34

                  @jsulm

                  "there are no .h files for QMainWindow under Qt5 anywhere" - of course there is if you installed qtwidgets module, see https://doc.qt.io/qt-5/qmainwindow.html

                  not an install link

                  J Offline
                  J Offline
                  jsulm
                  Lifetime Qt Champion
                  wrote on 23 Feb 2022, 05:52 last edited by
                  #37

                  @micha_eleric said in how to fix linker error in eclipse on linux:

                  not an install link

                  I don't know what this means...
                  If you installed Qt5 properly there will be QMainWindow header file.
                  This thread is already 36 posts long. Maybe you should do what was suggested? Like setting proper lib folder?

                  https://forum.qt.io/topic/113070/qt-code-of-conduct

                  M 1 Reply Last reply 23 Feb 2022, 05:55
                  0
                  • J jsulm
                    23 Feb 2022, 05:52

                    @micha_eleric said in how to fix linker error in eclipse on linux:

                    not an install link

                    I don't know what this means...
                    If you installed Qt5 properly there will be QMainWindow header file.
                    This thread is already 36 posts long. Maybe you should do what was suggested? Like setting proper lib folder?

                    M Offline
                    M Offline
                    micha_eleric
                    wrote on 23 Feb 2022, 05:55 last edited by
                    #38

                    @jsulm said in how to fix linker error in eclipse on linux:

                    @micha_eleric said in how to fix linker error in eclipse on linux:

                    not an install link

                    I don't know what this means...
                    If you installed Qt5 properly there will be QMainWindow header file.
                    This thread is already 36 posts long. Maybe you should do what was suggested? Like setting proper lib folder?

                    set proper lib folder is what i have been trying

                    J 1 Reply Last reply 23 Feb 2022, 05:57
                    0
                    • M micha_eleric
                      23 Feb 2022, 05:55

                      @jsulm said in how to fix linker error in eclipse on linux:

                      @micha_eleric said in how to fix linker error in eclipse on linux:

                      not an install link

                      I don't know what this means...
                      If you installed Qt5 properly there will be QMainWindow header file.
                      This thread is already 36 posts long. Maybe you should do what was suggested? Like setting proper lib folder?

                      set proper lib folder is what i have been trying

                      J Offline
                      J Offline
                      jsulm
                      Lifetime Qt Champion
                      wrote on 23 Feb 2022, 05:57 last edited by
                      #39

                      @micha_eleric said in how to fix linker error in eclipse on linux:

                      set proper lib folder is what i have been trying

                      But why are you still setting wrong folder?
                      I repeat it once more: /lib/x86_64-linux-gnu should be the correct one not /usr/include/qt4 /usr/include/qt4/QtWidgets...

                      https://forum.qt.io/topic/113070/qt-code-of-conduct

                      M 1 Reply Last reply 23 Feb 2022, 05:58
                      0
                      • J jsulm
                        23 Feb 2022, 05:57

                        @micha_eleric said in how to fix linker error in eclipse on linux:

                        set proper lib folder is what i have been trying

                        But why are you still setting wrong folder?
                        I repeat it once more: /lib/x86_64-linux-gnu should be the correct one not /usr/include/qt4 /usr/include/qt4/QtWidgets...

                        M Offline
                        M Offline
                        micha_eleric
                        wrote on 23 Feb 2022, 05:58 last edited by
                        #40

                        @jsulm said in how to fix linker error in eclipse on linux:

                        @micha_eleric said in how to fix linker error in eclipse on linux:

                        set proper lib folder is what i have been trying

                        But why are you still setting wrong folder?
                        I repeat it once more: /lib/x86_64-linux-gnu should be the correct one not /usr/include/qt4 /usr/include/qt4/QtWidgets...

                        because it is the only dir that has .h files

                        J 1 Reply Last reply 23 Feb 2022, 06:03
                        0
                        • M Offline
                          M Offline
                          micha_eleric
                          wrote on 23 Feb 2022, 06:01 last edited by micha_eleric
                          #41

                          g++ -L/usr/lib/x86_64-linux-gnu -o "GUI2" ./src/CGUI.o ./src/Main.o

                          /usr/bin/ld: ./src/CGUI.o: in function `CGUI::CGUI(QWidget*)':

                          /home/michaeleric/eclipse-workspace/GUI2/Debug/../src
                          /CGUI.cpp:10: undefined reference to QMainWindow::QMainWindow(QWidget*, QFlags<Qt::WindowType>)' /usr/bin/ld: /home/michaeleric/eclipse-workspace/GUI2/Debug/../src/CGUI.cpp:10: undefined reference to vtable for CGUI'

                          1 Reply Last reply
                          0
                          • M micha_eleric
                            23 Feb 2022, 05:58

                            @jsulm said in how to fix linker error in eclipse on linux:

                            @micha_eleric said in how to fix linker error in eclipse on linux:

                            set proper lib folder is what i have been trying

                            But why are you still setting wrong folder?
                            I repeat it once more: /lib/x86_64-linux-gnu should be the correct one not /usr/include/qt4 /usr/include/qt4/QtWidgets...

                            because it is the only dir that has .h files

                            J Offline
                            J Offline
                            jsulm
                            Lifetime Qt Champion
                            wrote on 23 Feb 2022, 06:03 last edited by
                            #42

                            @micha_eleric said in how to fix linker error in eclipse on linux:

                            because it is the only dir that has .h files

                            Are you joking?
                            We are talking about folder containing LIBRARIES, not headers!
                            This tells you clearly that it is about libraries:
                            "under Properties->C/C++ Build->Settings->Tool Settings->GCC C++ Linker->Libraries->Libraries search path"

                            Could you please be so kind and set /lib/x86_64-linux-gnu there? Else I give up on this thread...

                            https://forum.qt.io/topic/113070/qt-code-of-conduct

                            1 Reply Last reply
                            0
                            • M Offline
                              M Offline
                              micha_eleric
                              wrote on 23 Feb 2022, 06:09 last edited by
                              #43

                              g++ -L/usr/lib/x86_64-linux-gnu -L/usr/lib/x86_64-linux-gnu/qt5 -L/usr/lib/qt5 -o "GUI2" ./src/CGUI.o ./src/Main.o

                              still gives same errors

                              1 Reply Last reply
                              0
                              • M Offline
                                M Offline
                                micha_eleric
                                wrote on 23 Feb 2022, 06:15 last edited by
                                #44

                                g++ -L/usr/lib/x86_64-linux-gnu -L/usr -L/ -L/usr/lib -L/usr/lib/x86_64-linux-gnu/qt5 -L/usr/lib/qt5 -o "GUI2" ./src/CGUI.o ./src/Main.o

                                gives same errors

                                i keep wandering if i properly installed qt, keep rechecking sudo install qt, and keep coming back to sites i already went to.

                                J 1 Reply Last reply 23 Feb 2022, 06:29
                                0
                                • M micha_eleric
                                  23 Feb 2022, 06:15

                                  g++ -L/usr/lib/x86_64-linux-gnu -L/usr -L/ -L/usr/lib -L/usr/lib/x86_64-linux-gnu/qt5 -L/usr/lib/qt5 -o "GUI2" ./src/CGUI.o ./src/Main.o

                                  gives same errors

                                  i keep wandering if i properly installed qt, keep rechecking sudo install qt, and keep coming back to sites i already went to.

                                  J Offline
                                  J Offline
                                  jsulm
                                  Lifetime Qt Champion
                                  wrote on 23 Feb 2022, 06:29 last edited by
                                  #45

                                  @micha_eleric -L is not enough. You also have to tell the linker which libraries exactly you want to link.
                                  This is done using -l parameter followed (without space) by the name of the library but without lib prefix and without .so extension.
                                  Like:

                                  -lQt5Gui
                                  

                                  https://forum.qt.io/topic/113070/qt-code-of-conduct

                                  M 1 Reply Last reply 23 Feb 2022, 06:37
                                  0
                                  • J jsulm
                                    23 Feb 2022, 06:29

                                    @micha_eleric -L is not enough. You also have to tell the linker which libraries exactly you want to link.
                                    This is done using -l parameter followed (without space) by the name of the library but without lib prefix and without .so extension.
                                    Like:

                                    -lQt5Gui
                                    
                                    M Offline
                                    M Offline
                                    micha_eleric
                                    wrote on 23 Feb 2022, 06:37 last edited by
                                    #46

                                    @jsulm i cant find any qmainwindow, mainwindow, anything close to mainwindow in /usr/lib/x86_64-linux-gnu/
                                    the only place anything close to mainwindow are .h files under qt4

                                    wandering if qt4 .h files is the issue

                                    J 1 Reply Last reply 23 Feb 2022, 07:06
                                    0
                                    • M Offline
                                      M Offline
                                      micha_eleric
                                      wrote on 23 Feb 2022, 06:48 last edited by
                                      #47

                                      g++ -L/usr/lib/x86_64-linux-gnu -L/usr -L/ -L/usr/lib -L/usr/lib/x86_64-linux-gnu/qt5 -L/usr/lib/qt5 -o "GUI2" ./src/CGUI.o ./src/Main.o /usr/lib/x86_64-linux-gnu/libQtGui.so
                                      /usr/bin/ld: ./src/CGUI.o: in function CGUI::CGUI(QWidget*)': /home/michaeleric/eclipse-workspace/GUI2/Debug/../src/CGUI.cpp:10: undefined reference to vtable for CGUI'
                                      /usr/bin/ld: /home/michaeleric/eclipse-workspace/GUI2/Debug/../src/CGUI.cpp:10: undefined reference to vtable for CGUI' /usr/bin/ld: ./src/CGUI.o: in function CGUI::~CGUI()':
                                      /home/michaeleric/eclipse-workspace/GUI2/Debug/../src/CGUI.cpp:15: undefined reference to vtable for CGUI' /usr/bin/ld: /home/michaeleric/eclipse-workspace/GUI2/Debug/../src/CGUI.cpp:15: undefined reference to vtable for CGUI'

                                      1 Reply Last reply
                                      0
                                      • M micha_eleric
                                        23 Feb 2022, 06:37

                                        @jsulm i cant find any qmainwindow, mainwindow, anything close to mainwindow in /usr/lib/x86_64-linux-gnu/
                                        the only place anything close to mainwindow are .h files under qt4

                                        wandering if qt4 .h files is the issue

                                        J Offline
                                        J Offline
                                        jsulm
                                        Lifetime Qt Champion
                                        wrote on 23 Feb 2022, 07:06 last edited by
                                        #48

                                        @micha_eleric said in how to fix linker error in eclipse on linux:

                                        i cant find any qmainwindow, mainwindow, anything close to mainwindow in /usr/lib/x86_64-linux-gnu/

                                        Of course not. QMainWindow is part of widgets module as you can easilly see in the documentation: https://doc.qt.io/qt-5/qmainwindow.html (qmake: QT += widgets)
                                        That means you should look for libQt5Widgets.so in /usr/lib/x86_64-linux-gnu.
                                        And "surprisingly" it is there in your own list of libs: /usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5

                                        https://forum.qt.io/topic/113070/qt-code-of-conduct

                                        M 1 Reply Last reply 23 Feb 2022, 07:16
                                        0
                                        • J jsulm
                                          23 Feb 2022, 07:06

                                          @micha_eleric said in how to fix linker error in eclipse on linux:

                                          i cant find any qmainwindow, mainwindow, anything close to mainwindow in /usr/lib/x86_64-linux-gnu/

                                          Of course not. QMainWindow is part of widgets module as you can easilly see in the documentation: https://doc.qt.io/qt-5/qmainwindow.html (qmake: QT += widgets)
                                          That means you should look for libQt5Widgets.so in /usr/lib/x86_64-linux-gnu.
                                          And "surprisingly" it is there in your own list of libs: /usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5

                                          M Offline
                                          M Offline
                                          micha_eleric
                                          wrote on 23 Feb 2022, 07:16 last edited by
                                          #49

                                          @jsulm g++ -L/usr/lib/x86_64-linux-gnu -L/usr -L/ -L/usr/lib -L/usr/lib/x86_64-linux-gnu/qt5 -L/usr/lib/qt5 -o "GUI2" ./src/CGUI.o ./src/Main.o /usr/lib/x86_64-linux-gnu/libQtGui.so /usr/lib/x86_64-linux-gnu/libQt5Widgets.so
                                          /usr/bin/ld: ./src/CGUI.o: in function CGUI::CGUI(QWidget*)': /home/michaeleric/eclipse-workspace/GUI2/Debug/../src/CGUI.cpp:10: undefined reference to vtable for CGUI'
                                          /usr/bin/ld: /home/michaeleric/eclipse-workspace/GUI2/Debug/../src/CGUI.cpp:10: undefined reference to vtable for CGUI' /usr/bin/ld: ./src/CGUI.o: in function CGUI::~CGUI()':
                                          /home/michaeleric/eclipse-workspace/GUI2/Debug/../src/CGUI.cpp:15: undefined reference to vtable for CGUI' /usr/bin/ld: /home/michaeleric/eclipse-workspace/GUI2/Debug/../src/CGUI.cpp:15: undefined reference to vtable for CGUI'

                                          J 1 Reply Last reply 23 Feb 2022, 07:19
                                          0

                                          39/58

                                          23 Feb 2022, 05:57

                                          • Login

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