我在Windows 7下编写Eclipse编程,并且在使用OpenCV库编译小程序时遇到问题(2.4.9) 以下是GCC ++编译器中的路径列表,包括: " C:\ OpenCv2.4.9 \的OpenCV \建立\包括" " C:\ OpenCv2.4.9 \的OpenCV \建立\包括\ OpenCV的" " C:\ OpenCv2.4.9 \的OpenCV \建立\包括\ opencv2"
我还添加了这些库:
并指出以下库搜索路径: " C:\ OpenCv2.4.9 \的OpenCV \建立\ 86 \ VC10 \ lib中" " C:\ OpenCv2.4.9 \的OpenCV \建立\ 64 \ VC10 \ lib中"
而我不明白的是,这个程序正在编译
#include <cv.h>
#include <highgui.h>
#include <iostream>
using namespace std;
using namespace cv ;
int main ( int argc, char **argv )
{
cvNamedWindow( "My Window", 1 );
IplImage *img = cvCreateImage( cvSize( 640, 480 ), IPL_DEPTH_8U, 1 );
CvFont font;
double hScale = 1.0;
double vScale = 1.0;
int lineWidth = 1;
cvInitFont( &font, CV_FONT_HERSHEY_SIMPLEX | CV_FONT_ITALIC,
hScale, vScale, 0, lineWidth );
cvPutText( img, "Hello World!", cvPoint( 200, 400 ), &font,
cvScalar( 255, 255, 0 ) );
cvShowImage( "My Window", img );
cvWaitKey();
return 0;
}
即使我没有得到它的输出,以及以下程序:
#include <cv.h>
#include <highgui.h >
#include <iostream>
#include "opencv2/core/core.hpp"
#include "opencv2/imgproc/imgproc.hpp"
#include "opencv2/highgui/highgui.hpp"
using namespace cv;
using namespace std;
int main( int argc, char** argv )
{
Mat image;
image = imread( argv[1], 1 );
if( argc != 2 || !image.data )
{
printf( "No image data \n" );
return -1;
}
namedWindow( "Display Image", CV_WINDOW_AUTOSIZE );
imshow( "Display Image", image );
waitKey(0);
return 0;
}
不编译,用红色加下代码中的opencv函数并显示这些消息:
D:\SVN\C++ Workspace\OpenCVTest\Debug/../src/main.cpp:25: undefined reference to `cv::imread(std::string const&, int)'
D:\SVN\C++ Workspace\OpenCVTest\Debug/../src/main.cpp:33: undefined reference to `cv::namedWindow(std::string const&, int)'
D:\SVN\C++ Workspace\OpenCVTest\Debug/../src/main.cpp:34: undefined reference to `cv::_InputArray::_InputArray(cv::Mat const&)'
D:\SVN\C++ Workspace\OpenCVTest\Debug/../src/main.cpp:34: undefined reference to `cv::imshow(std::string const&, cv::_InputArray const&)'
D:\SVN\C++ Workspace\OpenCVTest\Debug/../src/main.cpp:36: undefined reference to `cv::waitKey(int)'
src\main.o: In function `ZN2cv3MatD1Ev':
C:/OpenCv2.4.9/opencv/build/include/opencv2/core/mat.hpp:278: undefined reference to `cv::fastFree(void*)'
src\main.o: In function `ZN2cv3MataSERKS0_':
C:/OpenCv2.4.9/opencv/build/include/opencv2/core/mat.hpp:298: undefined reference to `cv::Mat::copySize(cv::Mat const&)'
有人可以帮我解决这个问题吗?感谢