Cant use shared libraries in Qt project -
i created c++ library project in qt creator. after building project have libmylib.so, .so.1, .so.1.0, .so.1.0.0, makefile , mylib.o files. added library headers other project , added path .pro file this:
libs += "/home/peter/workspace/build-libtester-desktop-release/libmylib.so"
when building application don't no such file error, when running this:
/home/peter/workspace/build-libtester-desktop-debug/libtester: error while loading shared libraries: libmylib.so.1: cannot open shared object file: no such file or directory
which can't understand, because it's right there next .so seem find, because when path wrong no such file or directory error when trying build project. explain i'm missing here?
thanks time.
you adding library incorrectly. doing:
libs += "/home/peter/workspace/build-libtester-desktop-release/libmylib.so"
instead of:
libs += -l"/home/peter/workspace/build-libtester-desktop-release" -lmylib
the first version works on windows, not linux.
basically, create library, named "libmylib.so", , specify path folder, prepended "-l" , "-lmylib" @ end, note it's not "-llibmylib", "-lmylib", despite fact .so name "libmylib".
look here: https://wiki.qt.io/how_to_create_a_library_with_qt_and_use_it_in_an_application more info.
Comments
Post a Comment