尝试编译一个简单的opencv c ++文件
Trying to compile a simple opencv c++ file
我是打开cv的新手。目前,我正在尝试测试是否可以运行一个简单的文件。
// Example showing how to read and write images
#include <opencv2/opencv.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <opencv/cvaux.h>
int main(int argc, char** argv)
{
IplImage * pInpImg = 0;
// Load an image from file - change this based on your image name
pInpImg = cvLoadImage("bear.jpg", CV_LOAD_IMAGE_UNCHANGED);
if(!pInpImg)
{
fprintf(stderr, "failed to load input imagen");
return -1;
}
// Write the image to a file with a different name,
// using a different image format -- .png instead of .jpg
if( !cvSaveImage("my_image_copy.png", pInpImg) )
{
fprintf(stderr, "failed to write image filen");
}
// Remember to free image memory after using it!
cvReleaseImage(&pInpImg);
return 0;
}
我编译了它:
g++ `pkg-config –cflags opencv` cv.cpp -o cv `pkg-config –libs opencv`
我收到此错误:
Undefined symbols for architecture x86_64:
"_cvLoadImage", referenced from:
_main in cv-zQ5X30.o
"_cvReleaseImage", referenced from:
_main in cv-zQ5X30.o
"_cvSaveImage", referenced from:
_main in cv-zQ5X30.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
我在这里迷路了,任何帮助将不胜感激。谢谢。
我认为问题可能是使用"-libs"和"-cflags"而不是"--libs"和"--cflags",请改用这个:
g++ `pkg-config --cflags opencv` cv.cpp -o cv `pkg-config --libs opencv`
相关文章:
- 我怎样才能简单地将opencv 包含在我的项目中与CMake
- OpenCV 简单 2D 矩阵乘法失败
- Alpine Docker容器中的简单OPENCV程序上的链接器错误
- FFMpeg与OpenCV的格式转换/简单转换
- 无法使用CMake编译简单的Opencv C++文件
- 简单的C OPENCV IMSHOW示例与分段故障崩溃
- 为什么对于简单的 StereoBM 算法,我的代码比 opencv 慢得多
- 是否有一个演示 C/C++ OpenCV 程序,可以从网络摄像头进行简单的球跟踪
- OpenCV简单代码编译成功,但在运行时崩溃
- 使用Qt Creator和OpenCV制作一个简单的程序
- OpenCV C++简单的对象跟踪
- C++OpenCV:应用二维卷积的最简单方法是什么
- OpenCV中颜色差异的简单度量
- 如何构建简单的OpenCV程序
- 简单的OpenCV命令可以在调试模式下工作,但不能在发布模式下工作
- OpenCV 2.2 VS2010 - 用非常简单的代码获取"Access violation reading"
- Windows 8.1 中 Visual Studio 12 中的 OpenCV 错误。这是调试时的简单代码,它说一些错误。我该如何解决这个问题?
- 哪个opencv cuda库我需要运行一个简单的opencv cuda程序
- OpenCV:用标量除Mat最简单的方法是什么?
- 简单的 OpenCV 程序无法运行;没有错误。现在怎么办?