以下是我的步骤:
1)创建命令行工具项目“OpenCV”
2)在/usr/local/lib下的工程中添加后缀为2.4.2的文件,如
“libopencv_calib3d.2.4.2.dylib”
3)将“/usr/local/include”添加到项目的标头搜索路径中
4)输入该程序:
#include <opencv2/opencv.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <opencv/cvaux.hpp>
int main(int argc, char** argv)
{
IplImage * pInpImg = 0;
// Load an image from file - change this based on your image name
pInpImg = cvLoadImage("my_image.jpg", CV_LOAD_IMAGE_UNCHANGED);
if(!pInpImg)
{
fprintf(stderr, "failed to load input image\n");
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 file\n");
}
// Remember to free image memory after using it!
cvReleaseImage(&pInpImg);
return 0;
}
但是,我收到错误:
ld: library not found for -lopencv_calib3d.2.4.2
clang: error: linker command failed with exit code 1 (use -v to see invocation)
哪里有问题?
我正在使用山狮和 Xcode 4.4
您不需要将 opencv 库添加到项目中,但需要链接到库并设置库搜索路径。我能够使用这些设置编译并运行您的程序:
Search paths:
![Search paths](https://i.stack.imgur.com/H4kc5.png)
Link to libraries:
![Linked libraries](https://i.stack.imgur.com/9EE3J.png)
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)