gpt4 book ai didi

c++ - Linux C++ 中的 Opencv 链接器

转载 作者:太空宇宙 更新时间:2023-11-04 03:57:55 25 4
gpt4 key购买 nike

大家好,我正在尝试链接一个用 C++ 编写的简单应用程序,其中我使用 opencv 库,在此应用程序中我使用 IP 摄像机。

我正在尝试使用以下命令为此应用程序创建可执行文件:

g++ IPCamera.cpp -o camera -L/usr/include/opencv2 -lopencv_core -pthread -lopencv_imgproc -lopencv_highgui -lopencv_ml

输出就像无法识别库一样,这是输出:

IPCamera.cpp:12:30: error: opencv2/opencv.hpp: No such file or directory
IPCamera.cpp:13:39: error: opencv2/highgui/highgui.hpp: No such file or directory
IPCamera.cpp:14:39: error: opencv2/imgproc/imgproc.hpp: No such file or directory
IPCamera.cpp:18:22: error: X11/Xlib.h: No such file or directory
IPCamera.cpp:23: error: 'cv' is not a namespace-name
IPCamera.cpp:23: error: expected namespace-name before ';' token
IPCamera.cpp: In function 'int main(int, char**)':
IPCamera.cpp:53: error: 'cv' has not been declared
IPCamera.cpp:53: error: expected ';' before 'cap'
IPCamera.cpp:59: error: 'Display' was not declared in this scope
IPCamera.cpp:59: error: 'disp' was not declared in this scope
IPCamera.cpp:59: error: 'XOpenDisplay' was not declared in this scope
IPCamera.cpp:60: error: 'Screen' was not declared in this scope
IPCamera.cpp:60: error: 'scrn' was not declared in this scope
IPCamera.cpp:60: error: 'DefaultScreenOfDisplay' was not declared in this scope
IPCamera.cpp:70: error: 'cv' has not been declared
IPCamera.cpp:70: error: expected ';' before 'frame'
IPCamera.cpp:73: error: 'cv' has not been declared
IPCamera.cpp:73: error: 'CV_WINDOW_NORMAL' was not declared in this scope
IPCamera.cpp:75: error: 'cvMoveWindow' was not declared in this scope
IPCamera.cpp:80: error: 'CV_WND_PROP_FULLSCREEN' was not declared in this scope
IPCamera.cpp:80: error: 'CV_WINDOW_FULLSCREEN' was not declared in this scope
IPCamera.cpp:80: error: 'cvSetWindowProperty' was not declared in this scope
IPCamera.cpp:96: error: 'cap' was not declared in this scope
IPCamera.cpp:99: error: 'frame' was not declared in this scope
IPCamera.cpp:106: error: 'cv' has not been declared
IPCamera.cpp:109: error: 'cv' has not been declared

所以我认为我不太喜欢这些库,有人可以帮助我吗?

非常感谢

最佳答案

我用的是这个

g++ main.cpp -o a.out `pkg-config opencv --libs --cflags`

所以对你来说应该是:

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

命令pkg-config opencv --libs --cflags将返回程序运行所需的所有标志。

请注意,OpenCV 已通过 pkg-config 注册。如果您从 Ubuntu 存储库安装了 OpenCV,它应该可以正常工作

关于c++ - Linux C++ 中的 Opencv 链接器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24046536/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com