【问题标题】:Opencv 2.4.2 installation for CC 的 Opencv 2.4.2 安装
【发布时间】:2012-09-16 11:03:05
【问题描述】:

我一直在尝试为我的 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。

谢谢

【问题讨论】:

  • 尝试从-I(和-L)值中删除双引号。
  • 那些双引号是用来封闭给定路径的。无论如何,我确实尝试了你的建议。没用
  • 显然 highgui.hpp 丢失或未按预期检测到,我会尝试解决此问题。检查它是否正确包含。新用户提示 - 如果您认为某个答案很好,请记住稍后返回并标记答案已接受。
  • 我已经检查了 highgui.hpp 文件。它非常有。我也检查了提供的路径。所以我真的只是卡住了。

标签: c opencv mingw


【解决方案1】:

我遇到过这个错误。您需要知道您是否不会使用 ffmpegs,您可以在 cmake 阶段之前禁用此设置。这个属性对 opencv 的大部分专业都是有效的。我认为你必须用它解决你的问题。

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

【讨论】:

    【解决方案2】:

    你在 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`
    

    (不要忘记反引号)

    【讨论】:

    • 输出:g++: 'pkg-config': 没有这样的文件或目录 g++: opencv: 没有这样的文件或目录
    • 你复制粘贴命令行了吗?带反引号 ``````
    猜你喜欢
    • 1970-01-01
    • 2013-11-11
    • 1970-01-01
    • 1970-01-01
    • 2012-09-28
    • 2023-03-16
    • 2012-07-21
    • 2012-06-23
    • 1970-01-01
    相关资源
    最近更新 更多