Link error: undefined reference to `PythonQt::init(int, QByteArray const&)'
Dynamic Python binding for Qt Applications
Brought to you by:
florianlink,
marcusbarann
I downloaded PythonQt3.1 and opened src.pro with QtCreator4.2.2 (QT 5.8.0), everything complied and linked fine under Ubuntu 16.04 (after commenting out the two hint buttons), I ended up with eight *.so files:
libPythonQt.so - 20 bytes
libPythonQt.so.1 - 20 bytes
libPythonQt.so.1.0 - 20 bytes
libPythonQt.so.1.0.0 - 3.4 MBytes
and their debug counterparts in /home/user/Downloads/PythonQt3.1/lib/
I created a simple program in QtCreator to test in /home/user/CppCode/StocksWeb/ with this pro file:
And this main code (after reducing it greatly):
The two cpp and ui files compile fine, however when linking I get this output in QtCreater:
After making no progress after serveral hours I decided to ask for help. Any hints or ideas would be greatly appreciated. Thanks!
I resolved it, I had to change the way the project file add paths to the libraries:
CONFIG(debug, debug|release): LIBS += -L$$PWD/../3rdParty/lib/ -lPythonQt_d
else: LIBS += -L$$PWD/../3rdParty/lib/ -lPythonQt
My normal path to 3rd party stuff is /home/user/CppCode/3rdParty/. Now everything appears to be right with the libraries and include files in the right place.
Just a reminder, once you have your libraries in a permenant place don't forget to run ldconfig to register them with the operating system.
Last edit: David Lyon 2017-04-28
excuse me,I just want to know where you found PythonQt_d.lib. I haven't found it in the pythonQt3.1 zip package.