how to fix linker error in eclipse on linux
-
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 functionCGUI::CGUI()': /home/michaeleric/eclipse-workspace/GUI2/Debug/../src/CGUI.cpp:10: undefined reference to
QMainWindow::QMainWindow(QWidget*, QFlagsQt::WindowType)'
/usr/bin/ld: /home/michaeleric/eclipse-workspace/GUI2/Debug/../src/CGUI.cpp:10: undefined reference tovtable 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 functionCGUI::~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 tovtable for CGUI' /usr/bin/ld: /home/michaeleric/eclipse-workspace/GUI2/Debug/../src/CGUI.cpp:15: undefined reference to
QMainWindow::~QMainWindow()'
/usr/bin/ld: ./src/Main.o: in functionmain': /home/michaeleric/eclipse-workspace/GUI2/Debug/../src/Main.cpp:14: undefined reference to
QApplication::QApplication(int&, char**, int)'
/usr/bin/ld: /home/michaeleric/eclipse-workspace/GUI2/Debug/../src/Main.cpp:17: undefined reference toQApplication::exec()' /usr/bin/ld: /home/michaeleric/eclipse-workspace/GUI2/Debug/../src/Main.cpp:14: undefined reference to
QApplication::~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 1based 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/QtGuiif:
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 recognizedif:
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 recognizedif it is a virtual function that has to be defined, then what would it be, other than constructor/destructor?
answer:
deleting:
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, did nothing, no new errors, nothing with previous errorsunder Properties->C/C++ Build->Settings->Tool Settings->GCC C++ Linker->Miscellaneous->Other objects /usr/lib/x86_64-linux-gnu/libQtGui.so
fixed errors, exposed new errors -
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 functionCGUI::CGUI()': /home/michaeleric/eclipse-workspace/GUI2/Debug/../src/CGUI.cpp:10: undefined reference to
QMainWindow::QMainWindow(QWidget*, QFlagsQt::WindowType)'
/usr/bin/ld: /home/michaeleric/eclipse-workspace/GUI2/Debug/../src/CGUI.cpp:10: undefined reference tovtable 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 functionCGUI::~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 tovtable for CGUI' /usr/bin/ld: /home/michaeleric/eclipse-workspace/GUI2/Debug/../src/CGUI.cpp:15: undefined reference to
QMainWindow::~QMainWindow()'
/usr/bin/ld: ./src/Main.o: in functionmain': /home/michaeleric/eclipse-workspace/GUI2/Debug/../src/Main.cpp:14: undefined reference to
QApplication::QApplication(int&, char**, int)'
/usr/bin/ld: /home/michaeleric/eclipse-workspace/GUI2/Debug/../src/Main.cpp:17: undefined reference toQApplication::exec()' /usr/bin/ld: /home/michaeleric/eclipse-workspace/GUI2/Debug/../src/Main.cpp:14: undefined reference to
QApplication::~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 1based 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/QtGuiif:
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 recognizedif:
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 recognizedif it is a virtual function that has to be defined, then what would it be, other than constructor/destructor?
answer:
deleting:
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, did nothing, no new errors, nothing with previous errorsunder Properties->C/C++ Build->Settings->Tool Settings->GCC C++ Linker->Miscellaneous->Other objects /usr/lib/x86_64-linux-gnu/libQtGui.so
fixed errors, exposed new errors@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 (-l) /usr/include/qt4/QtGui
/usr/include/qt4/QtGui contains header files, not libraries!
You need to specify the folder where Qt libraries are located.
Thoese should be somewhere in /usr/lib -
@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 (-l) /usr/include/qt4/QtGui
/usr/include/qt4/QtGui contains header files, not libraries!
You need to specify the folder where Qt libraries are located.
Thoese should be somewhere in /usr/lib@jsulm well. /usr/lib/qt5 only contains dir bin, which contains fixqt4headers.pl, moc, qdbus, qdbuscpp2xml, qdbusxml2cpp, qlalr, qmake, qvkgen, rcc, syncqt.pl, uic
if:
under Properties->C/C++ Build->Settings->Tool Settings->GCC C++ Linker->Libraries->Libraries (-l) /usr/lib/qt5/bin
error:
/usr/bin/ld: cannot find -l/usr/lib/qt5/bin/usr/lib/ only has qt5 dir, that may look like it has anything to do with qt
-
@jsulm well. /usr/lib/qt5 only contains dir bin, which contains fixqt4headers.pl, moc, qdbus, qdbuscpp2xml, qdbusxml2cpp, qlalr, qmake, qvkgen, rcc, syncqt.pl, uic
if:
under Properties->C/C++ Build->Settings->Tool Settings->GCC C++ Linker->Libraries->Libraries (-l) /usr/lib/qt5/bin
error:
/usr/bin/ld: cannot find -l/usr/lib/qt5/bin/usr/lib/ only has qt5 dir, that may look like it has anything to do with qt
@micha_eleric said in how to fix linker error in eclipse on linux:
/usr/lib/qt5/bin
You are setting include folder for Qt4, but here you're trying to add Qt5 lib folder!
What Qt version do you actually want to use?
What Qt version did you install and how? -
@micha_eleric said in how to fix linker error in eclipse on linux:
/usr/lib/qt5/bin
You are setting include folder for Qt4, but here you're trying to add Qt5 lib folder!
What Qt version do you actually want to use?
What Qt version did you install and how?@jsulm i installed qt4, but qt5 was the only qt dir made in /usr/lib
i am looking around in other dir for anything qt
-
@jsulm i installed qt4, but qt5 was the only qt dir made in /usr/lib
i am looking around in other dir for anything qt
@micha_eleric said in how to fix linker error in eclipse on linux:
i installed qt4
How?
Search in /usr/lib, /usr/lib64 for files containing "qt4" in their names. -
@micha_eleric said in how to fix linker error in eclipse on linux:
i installed qt4
How?
Search in /usr/lib, /usr/lib64 for files containing "qt4" in their names.@jsulm how i install qt4?
i did internet search for "sudo install qt4". i just redid search, but only came up with install qt5, however the numbers dont look the same.under /usr/lib:
python3.9
qt5
recovery-modeunder usr/lib64:
ld-linux-x86-64.so.2under /usr/include:
python3.8
qt4
rdma -
@jsulm how i install qt4?
i did internet search for "sudo install qt4". i just redid search, but only came up with install qt5, however the numbers dont look the same.under /usr/lib:
python3.9
qt5
recovery-modeunder usr/lib64:
ld-linux-x86-64.so.2under /usr/include:
python3.8
qt4
rdma@micha_eleric said in how to fix linker error in eclipse on linux:
under /usr/lib:
python3.9
qt5
recovery-mode
under usr/lib64:
ld-linux-x86-64.so.2There should be way more than that.
I suggested to search:find /usr/lib -name *qt4* find /usr/lib64 -name *qt4*
What Linux distribution do you use? Please also tell the version.
-
@micha_eleric said in how to fix linker error in eclipse on linux:
under /usr/lib:
python3.9
qt5
recovery-mode
under usr/lib64:
ld-linux-x86-64.so.2There should be way more than that.
I suggested to search:find /usr/lib -name *qt4* find /usr/lib64 -name *qt4*
What Linux distribution do you use? Please also tell the version.
@jsulm there is a lot more, i only listed what was before and after qt
looking back through command line, i wonder if i half installed
-
@micha_eleric said in how to fix linker error in eclipse on linux:
under /usr/lib:
python3.9
qt5
recovery-mode
under usr/lib64:
ld-linux-x86-64.so.2There should be way more than that.
I suggested to search:find /usr/lib -name *qt4* find /usr/lib64 -name *qt4*
What Linux distribution do you use? Please also tell the version.
@jsulm from https://ubuntuhandbook.org/index.php/2020/07/install-qt4-ubuntu-20-04/
i have:
sudo add-apt-repository ppa:rock-core/qt4
in command line.??anything else should be installed?
-
@jsulm from https://ubuntuhandbook.org/index.php/2020/07/install-qt4-ubuntu-20-04/
i have:
sudo add-apt-repository ppa:rock-core/qt4
in command line.??anything else should be installed?
@micha_eleric said in how to fix linker error in eclipse on linux:
sudo add-apt-repository ppa:rock-core/qt4
This does not install anything!
This command only adds a new source for packages.
You need to install needed packages using "apt install PACKET_NAME".One question: do you really need Qt4?
-
@micha_eleric said in how to fix linker error in eclipse on linux:
sudo add-apt-repository ppa:rock-core/qt4
This does not install anything!
This command only adds a new source for packages.
You need to install needed packages using "apt install PACKET_NAME".One question: do you really need Qt4?
@jsulm qt4 it is what i started with.
i also found:
sudo apt install qt4-dev-tools libqt4-dev libqt4-core libqt4-guiwhich seems to be from:
https://askubuntu.com/questions/1274134/cannot-install-qt-4-on-ubuntu-20-04-quite-universal-circuit-simulator-qucsthis is last i found with qt*, if it is not installing qt4, then i guess my errors have been found
sudo apt-get install qt5-default
results:
qt5-default is already the newest version (5.12.8+dfsg-0ubuntu2.1).however, there are no qt5 directory under /usr/include
-
@jsulm qt4 it is what i started with.
i also found:
sudo apt install qt4-dev-tools libqt4-dev libqt4-core libqt4-guiwhich seems to be from:
https://askubuntu.com/questions/1274134/cannot-install-qt-4-on-ubuntu-20-04-quite-universal-circuit-simulator-qucsthis is last i found with qt*, if it is not installing qt4, then i guess my errors have been found
sudo apt-get install qt5-default
results:
qt5-default is already the newest version (5.12.8+dfsg-0ubuntu2.1).however, there are no qt5 directory under /usr/include
@micha_eleric said in how to fix linker error in eclipse on linux:
@jsulm qt4 it is what i started with.
This is not a great/clear answer, as @jsulm is pointing out that Qt4 is very old. Do you have a choice to move to Qt5, or even (hesitantly!) Qt6?
-
@micha_eleric said in how to fix linker error in eclipse on linux:
@jsulm qt4 it is what i started with.
This is not a great/clear answer, as @jsulm is pointing out that Qt4 is very old. Do you have a choice to move to Qt5, or even (hesitantly!) Qt6?
@JonB it seems i already installed qt5. just it is not showing up under /usr/include
-
@JonB it seems i already installed qt5. just it is not showing up under /usr/include
@micha_eleric said in how to fix linker error in eclipse on linux:
i already installed qt5
What exactly? Which qt5 packages?
" just it is not showing up under /usr/include" - as I already told you b efore the libraries will NOT show up in that directory. Search for the qt5 libs like I suggested before:find /usr/lib -name *qt5* find /usr/lib64 -name *qt5*
Don't forget to also change include folders in your set-up as currently you use qt4 include folder.
-
@micha_eleric said in how to fix linker error in eclipse on linux:
i already installed qt5
What exactly? Which qt5 packages?
" just it is not showing up under /usr/include" - as I already told you b efore the libraries will NOT show up in that directory. Search for the qt5 libs like I suggested before:find /usr/lib -name *qt5* find /usr/lib64 -name *qt5*
Don't forget to also change include folders in your set-up as currently you use qt4 include folder.
@jsulm said in how to fix linker error in eclipse on linux:
find /usr/lib -name qt5
michaeleric@michaeleric-C7B250-CB-ML:/usr/lib$ find -name qt5
./qt5
./x86_64-linux-gnu/qt5
michaeleric@michaeleric-C7B250-CB-ML:/usr/lib$ cd /
michaeleric@michaeleric-C7B250-CB-ML:/$ cd /usr/lib64
michaeleric@michaeleric-C7B250-CB-ML:/usr/lib64$ find -name qt5
michaeleric@michaeleric-C7B250-CB-ML:/usr/lib64$ -
@jsulm said in how to fix linker error in eclipse on linux:
find /usr/lib -name qt5
michaeleric@michaeleric-C7B250-CB-ML:/usr/lib$ find -name qt5
./qt5
./x86_64-linux-gnu/qt5
michaeleric@michaeleric-C7B250-CB-ML:/usr/lib$ cd /
michaeleric@michaeleric-C7B250-CB-ML:/$ cd /usr/lib64
michaeleric@michaeleric-C7B250-CB-ML:/usr/lib64$ find -name qt5
michaeleric@michaeleric-C7B250-CB-ML:/usr/lib64$@micha_eleric Please read again what I suggested (hint: * is important)...
-
@micha_eleric Please read again what I suggested (hint: * is important)...
@jsulm the * was used, copied, pasted, but did not show on post.
-
@jsulm the * was used, copied, pasted, but did not show on post.
@micha_eleric Can you please answer questions?
I asked before: What exactly? Which qt5 packages? -
@micha_eleric Can you please answer questions?
I asked before: What exactly? Which qt5 packages?@jsulm sudo apt-get install qt5-default
from:
https://wiki.qt.io/Install_Qt_5_on_Ubuntu