2015-10-19 83 views
0

我一直在花费最近几天的时间试图解决我在编写我在opencv上发现的一个简单示例程序时遇到的错误。应用程序的代码可以在下面找到,命令和错误如下。任何和所有的帮助表示赞赏。在Raspberry Pi上编译C++ opencv应用程序错误

.cpp文件:

控制台命令和错误:

[email protected]_RasPi ~/opencv $ g++ -o cppTest cppTest.cpp -I/usr/local/include/ 

/tmp/ccA0pvw2.o: In function `main': 
cppTest.cpp:(.text+0x30): undefined reference to `cv::imread(cv::String const&, int)' 
cppTest.cpp:(.text+0x74): undefined reference to `cv::imshow(cv::String const&, cv::_InputArray const&)' 
cppTest.cpp:(.text+0x94): undefined reference to `cv::waitKey(int)' 
/tmp/ccA0pvw2.o: In function `cv::String::String(char const*)': 
cppTest.cpp:(.text._ZN2cv6StringC2EPKc[_ZN2cv6StringC5EPKc]+0x50): undefined reference to `cv::String::allocate(unsigned int)' 
/tmp/ccA0pvw2.o: In function `cv::String::~String()': 
cppTest.cpp:(.text._ZN2cv6StringD2Ev[_ZN2cv6StringD5Ev]+0x14): undefined reference to `cv::String::deallocate()' 
/tmp/ccA0pvw2.o: In function `cv::Mat::~Mat()': 
cppTest.cpp:(.text._ZN2cv3MatD2Ev[_ZN2cv3MatD5Ev]+0x3c): undefined reference to `cv::fastFree(void*)' 
/tmp/ccA0pvw2.o: In function `cv::Mat::release()': 
cppTest.cpp:(.text._ZN2cv3Mat7releaseEv[_ZN2cv3Mat7releaseEv]+0x68): undefined reference to `cv::Mat::deallocate()' 
collect2: error: ld returned 1 exit status 
+0

可能的重复:[什么是未定义的引用/未解析的外部符号错误,以及如何修复它?](http://stackoverflow.com/questions/12573816/what-is-an-undefined-reference-unresolved-external-symbol-error-and-how-doi-i-fix) –

回答

0

你有你的二进制对OpenCV的链接......假设你正确安装的OpenCV这是可以做到的:

g++ -o cppTest cppTest.cpp -lopencv_core -lopencv_highgui -lopencv_imgproc