Reputation: 583
I am fairly new to Qt 5 and Qt Creator . I created a library project called D20Controls. I have the D20Controls.lib file. In my project, I want to use classes of my lib D20Controls. So I right-click on my project and do Add Library... I choose External library and I browse up to my D20Controls.Lib file. Now everything seems to be added correctly to my .pro file.
win32:CONFIG(release, debug|release): LIBS += -L$$PWD/../../build-D20Controls-Desktop_Qt_5_1_1_MSVC2012_64bit-Debug/release/ -lD20Controls
else:win32:CONFIG(debug, debug|release): LIBS += -L$$PWD/../../build-D20Controls-Desktop_Qt_5_1_1_MSVC2012_64bit-Debug/debug/ -lD20Controls
INCLUDEPATH += $$PWD/../../build-D20Controls-Desktop_Qt_5_1_1_MSVC2012_64bit-Debug/debug
DEPENDPATH += $$PWD/../../build-D20Controls-Desktop_Qt_5_1_1_MSVC2012_64bit-Debug/debug
win32:CONFIG(release, debug|release): PRE_TARGETDEPS += $$PWD/../../build-D20Controls-Desktop_Qt_5_1_1_MSVC2012_64bit-Debug/release/D20Controls.lib
else:win32:CONFIG(debug, debug|release): PRE_TARGETDEPS += $$PWD/../../build-D20Controls-Desktop_Qt_5_1_1_MSVC2012_64bit-Debug/debug/D20Controls.lib
but when I want to use it in my project
#include <D20Controls>
or any .h file in it, I can't compile error like :
...main.cpp:4: error: C1083: Cannot open include file: 'D20Controls': No such file or directory
How can I do use my lib ? (I have tried static linking and dynamic linking)
What am I missing ?
Upvotes: 1
Views: 2117
Reputation: 62777
Steps to solve a problem like this:
Find D20Controls.h
in your file system. If there are several, decide which is the correct one you want to include.
Find one actually executed compile command (for example one which has -o main.o
and main.cpp
in it), there are several but they should normally have same -I
flags within one project. If you compile from Qt Creator, look in the "Compile Output" tab at the bottom of the screen. If you compile from command line, scroll up or even copy-paste to some editor.
See if there is -I...something...
option on the compile command, which matches the location of correct include file.
If not, add or fix it in the .pro
file, re-run qmake, build.
Above applies for finding headers, and -I
flag for compile command, which specifies include path. If it is linker that complains (which usually happens in case like this, after you fix includes), then find the link command (one with bunch of .o
files, and something like -o final-program-name
), and look for -L
option, which specifies link paths.
Upvotes: 1