简体   繁体   English

包含在Qt Creator中添加外部库的路径?

[英]Include path for adding an external library in Qt Creator?

I am trying to include the pre-compiled (MSVC2012) OpenCV static libraries into Qt Creator but I am unsure what the include path is about as per this image: 我试图将预编译的(MSVC2012)OpenCV静态库包含到Qt Creator中,但我不确定包含该路径的内容是什么: http://i.stack.imgur.com/Pmsqq.png

Here is an image of the precompiled OpenCV files that I downloaded: 这是我下载的预编译OpenCV文件的图像: http://i.stack.imgur.com/vNRNt.png

There are 3 directories: bin contains DLLs, lib contains small lib files (2 kb) so that QtCreator can understand the DLLs, and staticlib containts large lib files (1 mb) which are the static libraries that I'm trying to link against. 有3个目录:bin包含DLL,lib包含小的lib文件(2 kb),因此QtCreator可以理解DLL,而staticlib包含大型lib文件(1 mb),这些是我试图链接的静态库。

The library file/path is something like C:\\opencv\\build\\x86\\vc11\\staticlib\\opencv_features2d247d.lib , right? 库文件/路径类似于C:\\opencv\\build\\x86\\vc11\\staticlib\\opencv_features2d247d.lib ,对吗? There are roughly 50 lib files. 大约有50个lib文件。 Do I have to each one manually? 我是否需要手动操作?

See the documentation for include path , and libs . 请参阅包含路径的文档。

Also note that you need to link with the files ending with 'd' in the debug build and the others in release (also if you use x86 and x64 builds, you should use the correct libraries), here is a sample from a test .pro (i only use x86 and vc10): 另请注意,您需要链接调试版本中以'd'结尾的文件和发行版中的其他文件(如果您使用x86和x64版本,则应使用正确的库),这是测试中的示例。亲(我只使用x86和vc10):

INCLUDEPATH += D:\\ProgrammingTools\\opencv\\build\\include

CONFIG( debug, debug|release ) {
LIBS += -LD:\\ProgrammingTools\\opencv\\build\\x86\\vc10\\lib\
    -lopencv_core246d\
    -lopencv_highgui246d\
    -lopencv_imgproc246d\
    -lopencv_features2d246d\
}
else {
LIBS += -LD:\\ProgrammingTools\\opencv\\build\\x86\\vc10\\lib\
    -lopencv_core246\
    -lopencv_highgui246\
    -lopencv_imgproc246\
    -lopencv_features2d246\
}

Notice that there is -L__NO_SPACE_ PATHTOLIB and -l _NOSPACE__libname, you don't need to add all the lib files, you only add the ones that you use functions from, and also the samples include files like this: 请注意,有-L__NO_SPACE_ PATHTOLIB和-l _NOSPACE__libname,您不需要添加所有lib文件,只需添加使用函数的文件,并且示例包含如下文件:

#include <opencv2/opencv.hpp>

so the include-path ends in a folder that contains two folders (not the actual header files) 所以include-path在包含两个文件夹(不是实际的头文件)的文件夹中结束

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM