我在Ubuntu上並且想要在自定義目錄上安裝不同版本的OpenCV(2.4.13)。我跟着這個教程在這裏:http://code.litomisky.com/2014/03/09/how-to-have-multiple-versions-of-the-same-library-side-by-side/OpenCV無法在自定義目錄中編譯
我不能得到這個簡單的main.cpp程序來編譯。我不能創建一個CV ::墊的形象,但我能獲得OpenCV的版本就好了!:
#include <iostream>
#include <opencv2/core/version.hpp>
#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <opencv2/imgproc/imgproc.hpp>
int main(int argc, char ** argv)
{
std::cout << "OpenCV version: "
<< CV_MAJOR_VERSION << "."
<< CV_MINOR_VERSION << "."
<< CV_SUBMINOR_VERSION
<< std::endl;
cv::Mat image; //without this line, it works!
return 0;
}
這裏是我的makefile:
CPP = g++ -std=c++0x
# OpenCV 2.4.13
CPPFLAGS = -L/home/myname/Desktop/myfolder/rewrite/opencv-2.4.13/release/installed/lib \
-I/home/myname/Desktop/myfolder/rewrite/opencv-2.4.13/release/installed/include
all: test
test: main.cpp
$(CPP) $(CPPFLAGS) $^ -o [email protected]
這是編譯器錯誤:
/tmp/ccyrdd7H.o: In function `cv::Mat::~Mat()':
main.cpp:(.text._ZN2cv3MatD1Ev[cv::Mat::~Mat()]+0x39): undefined reference to `cv::fastFree(void*)'
/tmp/ccyrdd7H.o: In function `cv::Mat::release()':
main.cpp:(.text._ZN2cv3Mat7releaseEv[cv::Mat::release()]+0x47): undefined reference to `cv::Mat::deallocate()'
collect2: ld returned 1 exit status
make: *** [test] Error 1
嗨,感謝您的評論。爲什麼我可以用這個makefile獲得版本號,但是我不能用完全相同的makefile創建一個cv :: Mat? – user1431515
你在說什麼'Makefile'? –