I have included the headers in Qt for my project, but the compiler is still not able to identify the headers. Libraries once included created its own includepath and depend.
Any help appriciated:
`INCLUDEPATH += $$PWD/../HDE/x86.linux/include
DEPENDPATH += $$PWD/../HDE/x86.linux/include
unix:!macx: LIBS += -L$$PWD/../HDE/x86.linux/lib/ -lddskernel
INCLUDEPATH += $$PWD/../HDE/x86.linux/include
DEPENDPATH += $$PWD/../HDE/x86.linux/include
unix:!macx: LIBS += -L$$PWD/../HDE/x86.linux/examples/dcps/Tutorial/cpp/standalone/ -lsacpp_tutorial_types
INCLUDEPATH += $$PWD/../HDE/x86.linux/examples/dcps/Tutorial/cpp/standalone
DEPENDPATH += $$PWD/../HDE/x86.linux/examples/dcps/Tutorial/cpp/standalone
unix:!macx: LIBS += -L$$PWD/../../../usr/lib/i386-linux-gnu/ -lpthread
INCLUDEPATH += $$PWD/../../../usr/lib/i386-linux-gnu
DEPENDPATH += $$PWD/../../../usr/lib/i386-linux-gnu`
All you have to do is also include the path for the header files in .pro file.
for instance if the header file is at location /home/jack/Myproject
then just write the below in the .pro file
INCLUDEPATH +=$$PWD/../Myproject
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 installed libfreenect. I opened QT and began to coding. When I use libfreenect.h no error occurres. But when I use libfreenect.hpp, this error occurred:"error: libusb.h: No such file or directory"
contents of .pro file is:
QT += core
QT -= gui
CONFIG += c++11
TARGET = 12moharram
CONFIG += console
CONFIG -= app_bundle
TEMPLATE = app
SOURCES += main.cpp
win32:CONFIG(release, debug|release): LIBS += -L$$PWD/../../../usr/local/lib/release/ -lfreenect
else:win32:CONFIG(debug, debug|release): LIBS += -L$$PWD/../../../usr/local/lib/debug/ -lfreenect
else:unix: LIBS += -L$$PWD/../../../usr/local/lib/ -lfreenect
INCLUDEPATH += $$PWD/../../../usr/local/include
DEPENDPATH += $$PWD/../../../usr/local/include
Where is the problem?
Probably libfreenect.h and libfreenect.hpp are themselves including other files, for a reason that I cannot understand libfreenect.hpp is including libusb.h and libfreenect.h is not. Probably libusb.h is not in your INCLUDEPATH.
I would first try to find libusb.h, if it is not present install it (you will probably have to install libusb-dev (debian style). Once you are sure libsub.h is present make sure is in the INCLUDEPATH, in case change the INCLUDEPATH in your .pro file.
This should fix this specific problem but after you fix this there can be more, good luck.
There is a high chance that this might get downvoted, but I am still posting this since I did not find the answer anywhere. I have added a Static External Library to my Project and this is how the MyApp.pro looks like at the moment:
win32:CONFIG(release, debug|release): LIBS += -L$$PWD/../common/build-CommonLib-Desktop_Qt_5_3_MSVC2012_OpenGL_32bit-Release/release/ -lCommonLib
else:win32:CONFIG(debug, debug|release): LIBS += -L$$PWD/../common/build-CommonLib-Desktop_Qt_5_3_MSVC2012_OpenGL_32bit-Release/release/ -lCommonLibd
else:unix: LIBS += -L$$PWD/../common/build-CommonLib-Desktop_Qt_5_3_MSVC2012_OpenGL_32bit-Release/release/ -lCommonLib
INCLUDEPATH += $$PWD/../common/build-CommonLib-Desktop_Qt_5_3_MSVC2012_OpenGL_32bit-Release/release
DEPENDPATH += $$PWD/../common/build-CommonLib-Desktop_Qt_5_3_MSVC2012_OpenGL_32bit-Release/release
win32-g++:CONFIG(release, debug|release): PRE_TARGETDEPS += $$PWD/../common/build-CommonLib-Desktop_Qt_5_3_MSVC2012_OpenGL_32bit-Release/release/libCommonLib.a
else:win32-g++:CONFIG(debug, debug|release): PRE_TARGETDEPS += $$PWD/../common/build-CommonLib-Desktop_Qt_5_3_MSVC2012_OpenGL_32bit-Release/release/libCommonLibd.a
else:win32:!win32-g++:CONFIG(release, debug|release): PRE_TARGETDEPS += $$PWD/../common/build-CommonLib-Desktop_Qt_5_3_MSVC2012_OpenGL_32bit-Release/release/CommonLib.lib
else:win32:!win32-g++:CONFIG(debug, debug|release): PRE_TARGETDEPS += $$PWD/../common/build-CommonLib-Desktop_Qt_5_3_MSVC2012_OpenGL_32bit-Release/release/CommonLibd.lib
else:unix: PRE_TARGETDEPS += $$PWD/../common/build-CommonLib-Desktop_Qt_5_3_MSVC2012_OpenGL_32bit-Release/release/libCommonLib.a
However, I am still unsure as how to refer to the Library (and a specific header file in there) from a header file in my project. I tried doing #include<CommonLib/Test.h> but it does not recognize either CommonLib or CommonLib/Test.h.
Your INCLUDEPATH points to the build directory, while library headers are most likely in the directory with CommonLib sources.
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
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