无法在linux上运行BRIEF_demo

时间:2012-06-04 05:25:58

标签: c++ c linux opencv

我正在尝试在我的linux环境中运行BRIEF_demo-0.5 .. 按照自述文件中的说明,我将目录更改为文件BRIEF_demo-0.5并键入make但我收到以下错误..

g++ `pkg-config opencv --libs` main.o BRIEF.o -o BRIEF_demo
main.o: In function `matchDescriptors(CvMat&, CvMat&, std::vector<std::bitset<256ul>, std::allocator<std::bitset<256ul> > >, std::vector<std::bitset<256ul>, std::allocator<std::bitset<256ul> > >, std::vector<cv::KeyPoint, std::allocator<cv::KeyPoint> > const&, std::vector<cv::KeyPoint, std::allocator<cv::KeyPoint> > const&) [clone .constprop.66]':
main.cpp:(.text+0x1f6): undefined reference to `cvInitMatHeader'
main.cpp:(.text+0x218): undefined reference to `cvInitMatHeader'
main.o: In function `drawQuadrangle(_IplImage*, int, int, int, int, int, int, int, int, CvScalar, int) [clone .constprop.71]':
main.cpp:(.text+0x2d5): undefined reference to `cvLine'
main.cpp:(.text+0x333): undefined reference to `cvLine'
main.cpp:(.text+0x398): undefined reference to `cvLine'
main.cpp:(.text+0x3f2): undefined reference to `cvLine'
main.o: In function `waitKeyAndHandleKeyboardInput(int)':
main.cpp:(.text+0x485): undefined reference to `cvWaitKey'
main.o: In function `drawQuadrangle(_IplImage*, int, int, int, int, int, int, int, int, CvScalar, int)':
main.cpp:(.text+0x5c6): undefined reference to `cvLine'
main.cpp:(.text+0x625): undefined reference to `cvLine'
main.cpp:(.text+0x68d): undefined reference to `cvLine'
main.cpp:(.text+0x6e4): undefined reference to `cvLine'
main.o: In function `drawAPlus(_IplImage*, int, int)':
main.cpp:(.text+0x867): undefined reference to `cvLine'
main.o:main.cpp:(.text+0x8ce): more undefined references to `cvLine' follow
main.o: In function `takeNewFrame()':
main.cpp:(.text+0x99c): undefined reference to `cvQueryFrame'
main.cpp:(.text+0x9be): undefined reference to `cvCvtColor'
main.o: In function `showMatches(int)':
main.cpp:(.text+0xb37): undefined reference to `cvLine'
main.o: In function `rotateImage(_IplImage*, _IplImage*, CvPoint2D32f const&, float)':
main.cpp:(.text+0xf0a): undefined reference to `cv2DRotationMatrix'
main.cpp:(.text+0xf68): undefined reference to `cvWarpAffine'
main.cpp:(.text+0xf90): undefined reference to `cvCreateMat'
main.o: In function `fpsCalculation()':
main.cpp:(.text+0x11ac): undefined reference to `cvGetTickCount'
main.cpp:(.text+0x11d0): undefined reference to `cvGetTickFrequency'
main.cpp:(.text+0x1211): undefined reference to `cvGetTickCount'
main.o: In function `showOutput(_IplImage*)':
main.cpp:(.text+0x12f5): undefined reference to `cvPutText'
main.cpp:(.text+0x1308): undefined reference to `cvGetTickFrequency'
main.cpp:(.text+0x13ab): undefined reference to `cvPutText'
main.cpp:(.text+0x13be): undefined reference to `cvGetTickFrequency'
main.cpp:(.text+0x1467): undefined reference to `cvPutText'
main.cpp:(.text+0x147a): undefined reference to `cvGetTickFrequency'
main.cpp:(.text+0x1529): undefined reference to `cvPutText'
main.cpp:(.text+0x153c): undefined reference to `cvGetTickFrequency'
main.cpp:(.text+0x15eb): undefined reference to `cvPutText'
main.cpp:(.text+0x15fe): undefined reference to `cvGetTickFrequency'
main.cpp:(.text+0x16ad): undefined reference to `cvPutText'
main.cpp:(.text+0x174a): undefined reference to `cvPutText'
main.o: In function `extractKeypoints(std::vector<cv::KeyPoint, std::allocator<cv::KeyPoint> >&, int, _IplImage*)':
main.cpp:(.text+0x17b3): undefined reference to `cvSetImageROI'
main.cpp:(.text+0x17c0): undefined reference to `cv::Mat::Mat(_IplImage const*, bool)'
main.cpp:(.text+0x17d3): undefined reference to `cv::FAST(cv::Mat const&, std::vector<cv::KeyPoint, std::allocator<cv::KeyPoint> >&, int, bool)'
main.cpp:(.text+0x183b): undefined reference to `cv::fastFree(void*)'
main.cpp:(.text+0x1843): undefined reference to `cvResetImageROI'
main.cpp:(.text+0x18c4): undefined reference to `cv::Mat::deallocate()'
main.cpp:(.text+0x18ec): undefined reference to `cv::Mat::deallocate()'
main.cpp:(.text+0x1938): undefined reference to `cv::fastFree(void*)'
main.o: In function `chooseFASTThreshold(_IplImage const*, int, int)':
main.cpp:(.text+0x197d): undefined reference to `cvGetSize'
main.cpp:(.text+0x198e): undefined reference to `cvCreateImage'
main.cpp:(.text+0x19ab): undefined reference to `cvCopy'
main.cpp:(.text+0x19f6): undefined reference to `cvReleaseImage'
main.o: In function `saveNewTemplate()':
main.cpp:(.text+0x1b50): undefined reference to `cvCopy'
main.cpp:(.text+0x1b5a): undefined reference to `cvReleaseImage'
main.cpp:(.text+0x1b6c): undefined reference to `cvCreateImage'
main.cpp:(.text+0x1b7d): undefined reference to `cvReleaseImage'
main.cpp:(.text+0x1b8f): undefined reference to `cvCreateImage'
main.cpp:(.text+0x1bab): undefined reference to `cvSetImageROI'
main.cpp:(.text+0x1bc0): undefined reference to `cvCopy'
main.cpp:(.text+0x1bcc): undefined reference to `cvResetImageROI'
main.cpp:(.text+0x1be1): undefined reference to `cvSetImageROI'
main.cpp:(.text+0x1bf6): undefined reference to `cvCopy'
main.cpp:(.text+0x1c02): undefined reference to `cvResetImageROI'
main.o: In function `learnTemplate()':
main.cpp:(.text+0x20da): undefined reference to `cvGetSize'
main.cpp:(.text+0x20ed): undefined reference to `cvCreateImage'
main.cpp:(.text+0x2106): undefined reference to `cvCopy'
main.cpp:(.text+0x2162): undefined reference to `cvReleaseImage'
main.cpp:(.text+0x21c0): undefined reference to `cvCreateImage'
main.cpp:(.text+0x21d9): undefined reference to `cvResize'
main.cpp:(.text+0x2259): undefined reference to `cv2DRotationMatrix'
main.cpp:(.text+0x22b7): undefined reference to `cvWarpAffine'
main.cpp:(.text+0x2323): undefined reference to `cvReleaseImage'
main.cpp:(.text+0x2351): undefined reference to `cvGetSize'
main.cpp:(.text+0x235e): undefined reference to `cvCreateImage'
main.cpp:(.text+0x239e): undefined reference to `cvCreateMat'
main.cpp:(.text+0x23ca): undefined reference to `cvReleaseImage'
main.o: In function `takeNewTemplateImage()':
main.cpp:(.text+0x24a5): undefined reference to `cvCopy'
main.cpp:(.text+0x253f): undefined reference to `cvRectangle'
main.o: In function `matchDescriptors(CvMat&, CvMat&, std::vector<std::bitset<256ul>, std::allocator<std::bitset<256ul> > >, std::vector<std::bitset<256ul>, std::allocator<std::bitset<256ul> > >, std::vector<cv::KeyPoint, std::allocator<cv::KeyPoint> > const&, std::vector<cv::KeyPoint, std::allocator<cv::KeyPoint> > const&)':
main.cpp:(.text+0x2736): undefined reference to `cvInitMatHeader'
main.cpp:(.text+0x2758): undefined reference to `cvInitMatHeader'
main.o: In function `init()':
main.cpp:(.text+0x27b4): undefined reference to `cvCreateCameraCapture'
main.cpp:(.text+0x27d0): undefined reference to `cvSetCaptureProperty'
main.cpp:(.text+0x27e9): undefined reference to `cvSetCaptureProperty'
main.cpp:(.text+0x2802): undefined reference to `cvCreateImage'
main.cpp:(.text+0x2822): undefined reference to `cvCreateImage'
main.cpp:(.text+0x2842): undefined reference to `cvCreateImage'
main.cpp:(.text+0x286c): undefined reference to `cvCreateImage'
main.cpp:(.text+0x2889): undefined reference to `cvCreateImage'
main.o:main.cpp:(.text+0x28a6): more undefined references to `cvCreateImage' follow
main.o: In function `init()':
main.cpp:(.text+0x294b): undefined reference to `cvNamedWindow'
main.cpp:(.text+0x295c): undefined reference to `cvSetMouseCallback'
main.o: In function `doDetection()':
main.cpp:(.text+0x2a4f): undefined reference to `cvGetTickCount'
main.cpp:(.text+0x2a8f): undefined reference to `cvGetTickCount'
main.cpp:(.text+0x2ab7): undefined reference to `cvGetTickCount'
main.cpp:(.text+0x2ae4): undefined reference to `cvGetTickCount'
main.cpp:(.text+0x2b04): undefined reference to `cvGetTickCount'
main.o:main.cpp:(.text+0x2e28): more undefined references to `cvGetTickCount' follow
main.o: In function `doDetection()':
main.cpp:(.text+0x3116): undefined reference to `cvFindHomography'
main.cpp:(.text+0x32b2): undefined reference to `cvCreateMat'
main.cpp:(.text+0x333f): undefined reference to `cvGetTickCount'
main.cpp:(.text+0x336a): undefined reference to `cvPerspectiveTransform'
main.cpp:(.text+0x336f): undefined reference to `cvGetTickCount'
main.o: In function `run()':
main.cpp:(.text+0x34f4): undefined reference to `cvWaitKey'
main.cpp:(.text+0x35a0): undefined reference to `cvQueryFrame'
main.cpp:(.text+0x35c2): undefined reference to `cvCvtColor'
main.cpp:(.text+0x35dc): undefined reference to `cvCopy'
main.cpp:(.text+0x3671): undefined reference to `cvQueryFrame'
main.cpp:(.text+0x3693): undefined reference to `cvCvtColor'
main.cpp:(.text+0x36a8): undefined reference to `cvCopy'
main.o: In function `showOutput(_IplImage*)':
main.cpp:(.text+0x175f): undefined reference to `cvShowImage'
main.o: In function `init()':
main.cpp:(.text+0x298f): undefined reference to `cvInitFont'
BRIEF.o: In function `CVLAB::BRIEF::~BRIEF()':
BRIEF.cpp:(.text+0x1c): undefined reference to `cvReleaseMat'
BRIEF.o: In function `CVLAB::BRIEF::~BRIEF()':
BRIEF.cpp:(.text+0x7c): undefined reference to `cvReleaseMat'
BRIEF.o: In function `CVLAB::BRIEF::BRIEF()':
BRIEF.cpp:(.text+0x1f3): undefined reference to `cvCreateMat'
BRIEF.o: In function `CVLAB::BRIEF::allocateIntegralImage(_IplImage const*)':
BRIEF.cpp:(.text+0x868): undefined reference to `cvReleaseMat'
BRIEF.cpp:(.text+0x877): undefined reference to `cvCreateMat'
BRIEF.o: In function `CVLAB::BRIEF::getBriefDescriptors(std::vector<std::bitset<256ul>, std::allocator<std::bitset<256ul> > >&, std::vector<cv::KeyPoint, std::allocator<cv::KeyPoint> > const&, _IplImage*)':
BRIEF.cpp:(.text+0x9cd): undefined reference to `cvReleaseMat'
BRIEF.cpp:(.text+0x9dd): undefined reference to `cvCreateMat'
BRIEF.cpp:(.text+0x9f0): undefined reference to `cvIntegral'
collect2: ld returned 1 exit status
make: *** [BRIEF_demo] Error 1

所以......按照我的指示,我尝试了这个命令 g ++ main.cpp Brief.cpp -lm -lml -lcvaux -lhighgui -lcv -lcxcore 我得到了

/usr/bin/ld: cannot find -lml
/usr/bin/ld: cannot find -lcvaux
/usr/bin/ld: cannot find -lhighgui
/usr/bin/ld: cannot find -lcv
/usr/bin/ld: cannot find -lcxcore
collect2: ld returned 1 exit status

当我输入pkg-config opencv --libs --cflags时,我得到了 -I / usr / local / include / opencv -I / usr / local / include -L / usr / local / lib -lopencv_core -lopencv_imgproc -lopencv_highgui -lopencv_ml -lopencv_video -lopencv_features2d -lopencv_calib3d -lopencv_objdetect -lopencv_contrib -lopencv_legacy -lopencv_flann

请帮忙......

1 个答案:

答案 0 :(得分:1)

这一行:

g++ `pkg-config opencv --libs` main.o BRIEF.o -o BRIEF_demo

应为:

g++ main.o BRIEF.o -o BRIEF_demo `pkg-config opencv --libs` 

或者,如果您正在编辑makefile:

$(EXECUTABLE): $(OBJECTS)
    $(CC) $(OBJECTS) -o $@ $(LDFLAGS)

即。将$(LDFLAGS)移到该行的末尾。

正在发生的事情是跳过了与依赖库的链接,因为在指定它们时实际上并不需要它们。一旦main.o和BRIEF.o文件被处理完毕,就需要它们,因此它们将在那时被链接。

这是一个链接的怪癖。