C的Opencv 2.4.2安装

时间:2012-09-16 11:03:06

标签: c opencv mingw

我一直在尝试为我的Windows 7 64位安装opencv。 我的基本目标是在C语言中使用opencv。我有borland和mingw编译器。 我完全按照描述使用Getting started with OpenCV 2.4 and MinGW on Windows 7指南。但我一直得到以下回应:

C:\Users\Rachit Dell\Pictures>g++ -I"C:\opencv\build\include" -L"C:\opencv\build
\x86\mingw\lib" loadimg.cpp -lopencv_core240 -lopencv_highgui240 -o loadimg
loadimg.cpp:1:39: error: opencv2/highgui/highgui.hpp: No such file or directory
loadimg.cpp:4: error: 'cv' is not a namespace-name
loadimg.cpp:4: error: expected namespace-name before ';' token
loadimg.cpp: In function 'int main(int, char**)':
loadimg.cpp:9: error: 'Mat' was not declared in this scope
loadimg.cpp:9: error: expected ';' before 'im'
loadimg.cpp:10: error: 'im' was not declared in this scope
loadimg.cpp:16: error: 'im' was not declared in this scope
loadimg.cpp:16: error: 'imshow' was not declared in this scope
loadimg.cpp:17: error: 'waitKey' was not declared in this scope

我使用的是版本2.4.2。

有人可以指导我。我只需要设置一个IDE来编译C中的opencv。

由于

2 个答案:

答案 0 :(得分:1)

我遇到了这个错误。您需要知道如果不使用ffmpegs,可以在cmake阶段之前禁用此设置。这个属性对opencv来说是最有效的。我认为你必须用它来解决你的问题。

否则,您可以转到cmake进程后创建的CMakeCache.txt来解决问题。您应该为某些库添加路径。

答案 1 :(得分:0)

您是否在MinGW中安装了pkg-config?尝试在MinGW控制台中输入pkg-config --cflags --libs opencv。它应该输出一些-I / c / opencv / build / include和-L / stuff。顺便说一下,我认为路径应该以MinGW方式输入,而不是以标准的Windows方式输入。如果pkg-config有效,您也可以使用以下命令编译代码:

g++ loadimg.cpp -o loadimg `pkg-config --cflags --libs opencv`

(不要忘记反引号)