lig*_*ist 3 opencv visual-studio-2010
我一直在尝试使用openCV 2.2的新Qt函数(参见http://opencv.willowgarage.com/documentation/cpp/qt_new_functions.html#index-1384)进行项目,但我一直收到错误:
1> main.cpp 1> main.obj:错误LNK2019:未解析的外部符号"void __cdecl cv :: displayStatusBar(class std :: basic_string,class std :: allocator> const&,class std :: basic_string,class std :: allocator> const&,int)"(?displayStatusBar @ cv @@ YAXABV?$ basic_string @ DU?$ char_traits @ D @ std @@ V?$ allocator @ D @ 2 @@ std @@ 0H @ Z)在函数中引用_main 1> C:\ Documents and Settings\Orange\my documents\visual studio 2010\Projects\FYP\FYP.exe:致命错误LNK1120:1未解析的外部
我正在使用Visual Studio 2010,windows xp,qt 4.7.1和openCV 2.2.
我已经在属性>链接器>输入下的项目设置中为openCV和qt添加了核心lib文件.我尝试编译并运行openCV代码时没有遇到任何问题,除非我尝试使用新的Qt函数,如displayStatusBar(...)和createButton(...).我一直在寻找一个解决方案,我现在仍然找不到一个,因为openCV2.2最近刚刚发布.有没有人尝试过并遇到过这个问题并有解决方案?
顺便说一下,我想使用openCV提供的函数来创建简单的窗口和按钮而不是qt是因为我希望避免在openCV中的Mat数据类型和Qt中的QImage之间进行转换.
在此先感谢任何回复.
附加代码:
#include <cv.h>
#include <highgui.h>
using namespace cv;
int main()
{
namedWindow("Test", CV_WINDOW_AUTOSIZE);
// ...
// Code links without problem when the following line is commented out.
displayStatusBar("Test", "Hello World", 5000);
return 0;
}
Run Code Online (Sandbox Code Playgroud)
我发现了问题所以我想我应该在这里发布一个答案,以便其他可能遇到同样问题的人受益.
基本上,默认情况下为OpenCv 2.2提供的二进制文件不包括Qt新函数.要启用它,需要下载OpenCV的来源和使用CMake的生成makefile和来源,包括Qt的新功能和编译从头源.
以下是大致要做的步骤:
而已.你现在应该有一个使用QT的OpenCV.
有关如何从头开始编译的说明,请参见OpenCv的网页:http://opencv.willowgarage.com/wiki/InstallGuide .