[Solved]Undefined reference problem
-
I've installed qxmpp library recently and wanted to write small program. I included QXmppClient.h and after some problems at start I managed to set it and included as any other qt header. But there came the problem, creating simple variable QXmppClient client; gave me these errors
/root/IM_client-build-desktop/../IM_client/reg_okno.cpp:47: error: undefined reference to
QXmppClient::QXmppClient(QObject*)' /root/IM_client-build-desktop/../IM_client/reg_okno.cpp:50: error: undefined reference to
QXmppClient::~QXmppClient()'I changed it to QXmppClient *client; and error disappeared but now after this client->connectToServer("blahblah","test"); I got the error again
/root/IM_client-build-desktop/../IM_client/reg_okno.cpp:56: error: undefined reference to `QXmppClient::connectToServer(QString const&, QString const&)'I don't think there is problem with header because after typing client-> qt creator showed up all existing members of QXmppClient class in menu (I don't know how its called :)) as expected.
I'll be thankful for any help or hint :) -
The example gave me this error when run
/root/static_im/qxmpp-0.7.6/examples/example_0_connected-build-desktop/example_0_connected: error while loading shared libraries: libqxmpp_d.so.0: cannot open shared object file: No such file or directory
I've tried to add LIBS += -L/usr/local/lib to .pro file to tell linker where to find lib but it didn't help, will be probably the same problem in my own code, how can I force linker to look there for the lib file?
-
Upper case 'L' defines the path of the library, but need also to specify the static part of the lib with lower case 'l'. See "this":http://qt-project.org/doc/qt-5.0/qtdoc/qmake-variable-reference.html#libs
-
changed it to LIBS += -L/usr/local/lib -lqxmpp_d but nothing happened, application still crashing with same message
-
Hi,
There's something not clear, once you have a problem when compiling, then when running the application.
So maybe a silly question but: are you sure you have libqxmpp_d.so.0 on your system ?
-
yes, the libqxmpp_d.so.0 file is link to shared library libqxmpp_d.so.0.7.6 it's in same directory as the lib, /usr/local/lib
-
Just to make things clear: did you build your application successfully ?
-
yes, no error nor warning when building it, only when I run application it crashes with that error
-
Then you need to update LD_LIBRARY_PATH and make it point also to /usr/local/lib.
By the way, developing (and generally doing anything) as root user is very dangerous, you could end up destroying your OS.
-
Thank you really much this was exactly the problem, next time I'll know :)