在Debian上编译OpenCV的错误

时间:2014-10-16 17:56:37

标签: c++ opencv netbeans compilation debian

我从Debian Wheezy(64位)的回购安装了OpenCV。我能够编译一个示例的源文件,但当它进入build步骤时会发生这种情况:

g++     -o dist/Debug/GNU-Linux-x86/opencvtestapp build/Debug/GNU-Linux-x86/main.o 

build/Debug/GNU-Linux-x86/main.o: In function `main':
/home/ ... /main.cpp:9: undefined reference to `cv::VideoCapture::VideoCapture(int)'
/home/ ... /main.cpp:11: undefined reference to `cv::VideoCapture::isOpened() const'
/home/ ... /main.cpp:16: undefined reference to `cv::VideoCapture::get(int)'
/home/ ... /main.cpp:17: undefined reference to `cv::VideoCapture::get(int)'
/home/ ... /main.cpp:21: undefined reference to `cv::namedWindow(std::string const&, int)'
/home/ ... /main.cpp:26: undefined reference to `cv::VideoCapture::read(cv::Mat&)'
/home/ ... /main.cpp:33: undefined reference to `cv::_InputArray::_InputArray(cv::Mat const&)'
/home/ ... /main.cpp:33: undefined reference to `cv::imshow(std::string const&, cv::_InputArray const&)'
/home/ ... /main.cpp:35: undefined reference to `cv::waitKey(int)'
/home/ ... /main.cpp:40: undefined reference to `cv::VideoCapture::~VideoCapture()'
/home/ ... /main.cpp:40: undefined reference to `cv::VideoCapture::~VideoCapture()'

build/Debug/GNU-Linux-x86/main.o: In function `cv::Mat::~Mat()':
/usr/include/opencv2/core/mat.hpp:297: undefined reference to `cv::fastFree(void*)'

build/Debug/GNU-Linux-x86/main.o: In function `cv::Mat::release()':
/usr/include/opencv2/core/mat.hpp:382: undefined reference to `cv::Mat::deallocate()'

collect2: error: ld returned 1 exit status
make[2]: *** [dist/Debug/GNU-Linux-x86/opencvtestapp] Error 1
make[2]: Leaving directory `/home/work/OpenCVTestApp'
make[1]: *** [.build-conf] Error 2
make[1]: Leaving directory `/home/work/OpenCVTestApp'
make: *** [.build-impl] Error 2

我正在使用NetBeans 8.0和OpenCV2.3(来自repo)。

有关我可能遗失的内容的任何建议吗?

谢谢!

1 个答案:

答案 0 :(得分:0)

@berak对他的评论是完全正确的,因为这就是问题所在。

我忘了将库添加到链接器配置中。 :P

2014年的2.3:我同意。我打算使用3.o alpha,但这就是repo所拥有的,我不想编译整个东西只是为了运行一些样本。

谢谢@berac!我希望这个问题对那里的人来说仍然有用。