c++ - Linker Error using g++ with Qt 4.5.1 -


i'm trying test out new dev environment , having problems referencing of required qt libraries.

first ran this:

$ g++ helloworld.c -o helloworld -i /usr/local/trolltech/qt-4.5.1/include/qtcore/ -i /usr/local/trolltech/qt-4.5.1/include/ 

and got error:

    /tmp/ccmsm4kz.o: in function `qstring::qstring(char const*)': helloworld.c:(.text._zn7qstringc2epkc[_zn7qstringc5epkc]+0x1d): undefined reference `qstring::fromascii_helper(char const*, int)' /tmp/ccmsm4kz.o: in function `qstring::~qstring()': helloworld.c:(.text._zn7qstringd2ev[_zn7qstringd5ev]+0x2d): undefined reference `qstring::free(qstring::data*)' collect2: ld returned 1 exit status 

so added reference qtcore library via:

$ g++ helloworld.c -o helloworld -i /usr/local/trolltech/qt-4.5.1/include/qtcore/ -i /usr/local/trolltech/qt-4.5.1/include/ -l /usr/local/trolltech/qt-4.5.1/lib -lqtcore 

which removed compile errors, when try run program error:

./helloworld: error while loading shared libraries: libqtcore.so.4: cannot open shared object file: no such file or directory 

i wasn't able find solution problem via google. have advice?

that error indicates while linker can find library @ compilation, can't find during runtime.

you should update ld_library_path include location this:

in ~.bashrc somewhere near bottom:

export ld_library_path=$ld_library_path:/usr/local/trolltech/qt-4.5.1/lib

alternatively, if want make persistent throughout system (and have root access), can make entry in /etc/ld.so.conf.d (on redhat, i'm not sure other distributions)

touch /etc/ld.so.conf.d/qt.conf

add path file, , update runtime via /sbin/ldconfig


Comments

Popular posts from this blog

java - Intellij Synchronizing output directories .. -

git - Initial Commit: "fatal: could not create leading directories of ..." -