2012-09-16 66 views
1

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

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编译OpenCV的在C.

感谢

+0

尝试从'-I'(和'-L')值中删除双引号。 – hmjd

+0

这些双引号用于包含给定的路径。无论如何,我没有尝试你的建议。没有工作 –

+0

明显highgui.hpp缺少或未检测到,因为它预计会,我会尽力解决这个问题。检查它是否包含正确。新的用户提示 - 记住稍后返回并标记回答,如果您认为一个很好的答案。 –

回答

0

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

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

(不要忘了反引号)

+0

输出:g ++:'pkg-config':没有这样的文件或目录g ++:opencv:没有这样的文件或目录 –

+0

你复制粘贴命令行吗?用反引号''''' – remi

+0

是的。尝试使用和不使用反引号。徒劳无功 –

1

我的事我都碰到这样的错误。你需要知道你是否不使用ffmpegs,你可以在cmake阶段之前禁用这个设置。该属性对于opencv的大部分特性都是有效的。我认为你必须用它解决你的问题。

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