【发布时间】:2014-10-19 19:16:36
【问题描述】:
我正在尝试在 64 位 Windows 7 系统中使用 Microsoft Visual Studio 2008 设置一个简单的 OpenCV 项目。我没有系统管理员权限,因此我不能在这里重新安装 OpenCV。
但是,我确实有 OpenCV 的 bin、include 和 lib 目录,它们是在类似的平台上编译的。
我启动了一个“Visual C++ -> General -> Empty Project”并创建了一个 .cpp 文件,内容如下:
#include <opencv/cv.h>
#include <opencv/highgui.h>
void main()
{
cv::Mat frame = cv::imread("D:\\Images\\lena.bmp");
cv::imwrite("D:\\lena_bw.bmp",frame);
}
在'Property->Configuration Property->C/C++->General->Additional Include Directories'中,我提供了OpenCV的'include'目录的链接。
在'Property->Configuration Property->Linker->Input->Additional Dependencies'中,我提供了opencv_core230.lib、opencv_highgui230.lib、opencv_imgproc230.lib等的路径
代码构建良好,但是当我运行它时,我得到:
Unhandled exception at 0x734761e7 in OpenCVTest.exe: 0xC0000005: Access violation reading location 0xcccccccc.
No symbols are loaded for any call stack frame. The source code cannot be displayed.
我自己的想法无处可去。我对 Visual Studio 平台有点陌生。
请帮我找出一种方法来完成这项工作。
++++++++++++++++++++++++++++++++++++++++++++++++++ +
在“发布”模式下运行时,在编译过程中出现以下错误:
1>HelloOpenCV.obj : error LNK2001: unresolved external symbol "public: __thiscall cv::_InputArray::_InputArray(class cv::Mat const &)" (??0_InputArray@cv@@QAE@ABVMat@1@@Z)
1>HelloOpenCV.obj : error LNK2001: unresolved external symbol "void __cdecl cv::fastFree(void *)" (?fastFree@cv@@YAXPAX@Z)
1>HelloOpenCV.obj : error LNK2001: unresolved external symbol "class cv::Mat __cdecl cv::imread(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &,int)" (?imread@cv@@YA?AVMat@1@ABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@H@Z)
1>HelloOpenCV.obj : error LNK2001: unresolved external symbol "public: void __thiscall cv::Mat::deallocate(void)" (?deallocate@Mat@cv@@QAEXXZ)
1>HelloOpenCV.obj : error LNK2001: unresolved external symbol "bool __cdecl cv::imwrite(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &,class cv::_InputArray const &,class std::vector<int,class std::allocator<int> > const &)" (?imwrite@cv@@YA_NABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@ABV_InputArray@1@ABV?$vector@HV?$allocator@H@std@@@3@@Z)
【问题讨论】:
-
你是否在
debug进行项目,如果是,请将其更改为Release,然后再次设置include,lib等。或如果你想继续工作在debug模式下,添加调试库,即 opencv_core230.lib 应该有 opencv_core230d.lib。 -
尝试了发布和调试...仍然没有运气。
-
你还需要为库添加路径,属性->配置属性->C/C++->常规->库目录OR属性->配置属性->C /C++->链接器->附加库依赖->添加包含lib的目录,路径应该有点像:
..\OpenCV\build\x64\vc9\lib如果vc不行就试试vc10。 -
请检查我的问题的更新...我尝试添加 lib 目录,但没有区别。
标签: visual-studio opencv visual-c++ configuration