请参阅Qt C ++项目中包含的库

时间:2014-10-14 14:08:45

标签: c++ qt static-libraries

这很有可能会被投票,但我仍然发布这个,因为我没有在任何地方找到答案。我已经为我的项目添加了一个静态外部库,这就是MyApp.pro目前的样子:

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

但是,我仍然不确定 如何从项目 中的头文件引用库(以及其中的特定头文件)。我尝试#include<CommonLib/Test.h>,但它无法识别CommonLibCommonLib/Test.h

1 个答案:

答案 0 :(得分:1)

您的INCLUDEPATH指向构建目录,而库标题很可能位于包含CommonLib源的目录中。