what is the best way to add additional compiled libraries to my qt project ?
For example boost or poco libs ?
Thanks :)
If you're using the GCC compiler add something like this to the .pro file:
For Boost:
INCLUDEPATH += d:/Biblioteki/C++/boost/boost_1_44_0a
LIBPATH += d:/Biblioteki/C++/boost/boost_1_44_0a/stage/lib
LIBS += -lboost_system-mgw44-mt-d-1_44
LIBS += -lboost_filesystem-mgw44-mt-d-1_44
LIBS += -lboost_date_time-mgw44-mt-d-1_44
For Poco:
INCLUDEPATH += d:/Biblioteki/C++/Poco/poco-1.3.6p2-mingw-qt2/include
LIBPATH += d:/Biblioteki/C++/Poco/poco-1.3.6p2-mingw-qt2/lib
LIBS += -lPocoFoundationd
LIBS += -lPocoNetd
LIBS += -lPocoUtild
LIBS += -lPocoXML
INCLUDEPATH - is the location of directory with header files
LIBPATH - is the location of directory with *.a files
LIBS - contains list of libraries you want to use in your application
Related
In my QtCreator C++ project I'm using subdirs template and have several subprojects including lib-project. In app-project I'm trying this:
win32:CONFIG(release, debug|release): LIBS += -L../Library/release -lLibrary
else:win32:CONFIG(debug, debug|release): LIBS += -L../Library/debug -lLibrary
else:unix: LIBS += -L../Library -lLibrary
On Linux it works well, but on Windows library compiles (there're .dll and .a files), linker links it (if I change the path to wrong, like -L../Library/debugg I have an error - can't find -lLibrary), but then I have "undefined reference to [my_classes]". INCLUDEPATH and DEPENDPATH are also correct (because it works on Linux):
INCLUDEPATH += $$PWD/.. $$PWD/../Library
DEPENDPATH += $$PWD/.. $$PWD/../Library
Also tried this:
LIBS += -L$$OUT_PWD/../Library/release -lLibrary
Same result, so what should I do?
I have a Qt project. I can add some libraries using the commands like:
LIBS += -lopencv_core
They work perfectly for me. However, if I check the output, I have there other libraries, too. For example /usr/lib64, without mentioning this anywhere in the project. How can I avoid that addition?
You can explicity remove these paths. For example, I use that to remove all standard path (lib and includes) :
unix {
LIBS -= -L/usr/lib/
LIBS -= -L/usr/lib64/
LIBS -= -L/usr/lib
LIBS -= -L/usr/lib64
INCLUDEPATH -= /usr/include/
INCLUDEPATH -= /usr/include
}
I have shared library(.so file) and I want to add that file into Qt .pro file.
How can I do it?
You should use the LIBS variable as vahancho suggests:
LIBS += -lQtSolutions_SingleApplication-2.6
# and more:
unix:LIBS += -lQxtCore -lQxtWeb -lQxtNetwork -lQtSolutions_IOCompressor-2.3
CONFIG(release, debug|release) {
win32:LIBS += -lbfd -liberty -limagehlp
}
# and so on
http://qt-project.org/doc/qt-4.8/qmake-variable-reference.html#libs
I am trying to include the assimp library (http://assimp.sourceforge.net/main_doc.html) for importing assets into my QT project.
I managed to include it in VS2012 but not in QT.
The import wizard gives me this code:
unix|win32: LIBS += -L$$PWD/assimp--3.0.1270-sdk/lib/assimp_debug-dll_win32/ -lassimp
INCLUDEPATH += $$PWD/assimp--3.0.1270-sdk/include
DEPENDPATH += $$PWD/assimp--3.0.1270-sdk/include
win32: PRE_TARGETDEPS += $$PWD/assimp--3.0.1270-sdk/lib/assimp_debug-dll_win32/assimp.lib
else:unix: PRE_TARGETDEPS += $$PWD/assimp--3.0.1270-sdk/lib/assimp_debug-dll_win32/libassimp.a
When i build the code it throws this error
undefined reference to `Assimp::Importer::Importer()'
If i understand it right:
QT / VS2012
INCLUDEPATH =Include directories
LIBS = Library directories
PRE_TARGETDEPS=Additional dependancies
Do i have to manualy add the location off the .dll file into .pro or what am i missing?
The library is called mod.lib, I have used the following lines to link the library. I also include its header file. Not sure what is wrong, but it kept giving me the undefined reference errors of library's functions when I try to use them in the code.
win32: CONFIG (release, debug|release): LIBS += -LC:/Users/J/proj -lmod
INCLUDEPATH += C:/Users/J/proj
DEPENDPATH += C:/Users/J/proj
win32: PRE_TARGETDEPS += C:/Users/J/proj/mod.lib
Thanks for answering.
Use
LIBS += -L/C:/Users/J/proj -lmod
Instead of
LIBS += -LC:/Users/J/proj -lmod
The proper way for adding a library is
LIBS += -L/path/to -lyourmodule