c++ - 使用已编译版本的 openCV 时出错

标签 c++ c linux opencv

我已经使用了用于 Raspberry Pi 的 openCV 的已编译版本。 link for anyone who is interested

尝试使用此命令行进行编译后 g++ test3.cpp -o test3 -I/usr/local/include/ -lraspicam -lraspicam_cv -L/opt/vc/lib -lmmal -lmmal_core -lmmal_util -I/usr/include -lopencv_core -lopencv_highgui -lopencv_imgproc -lwiringPi -lpthread

我收到以下错误行。

//usr/local/lib/libopencv_stitching.so.2.4: undefined reference to `cv::gpu::ensureSizeIsEnough(int, int, int, cv::gpu::GpuMat&)'

//usr/local/lib/libopencv_calib3d.so.2.4: undefined reference to `cv::parallel_for_(cv::Range const&, cv::ParallelLoopBody const&, double)'

//usr/local/lib/libopencv_calib3d.so.2.4: undefined reference to `typeinfo for cv::ParallelLoopBody'

//usr/local/lib/libopencv_calib3d.so.2.4: undefined reference to `cv::Mutex::unlock()'

//usr/local/lib/libopencv_calib3d.so.2.4: undefined reference to `cv::Mutex::lock()'

//usr/local/lib/libopencv_ocl.so.2.4: undefined reference to cv::TLSDataContainer::getData() const

//usr/local/lib/libopencv_features2d.so.2.4: undefined reference to cv::AlgorithmInfo::addParam(cv::Algorithm&, char const*, unsigned char&, bool, unsigned char (cv::Algorithm::)(), void (cv::Algorithm::)(unsigned char), std::basic_string, std::allocator > const&)

//usr/local/lib/libopencv_features2d.so.2.4: undefined reference to `cv::AlgorithmInfo::addParam(cv::Algorithm&, char const*, float&, bool, float (cv::Algorithm::)(), void (cv::Algorithm::)(float), std::basic_string, std::allocator > const&)'

//usr/local/lib/libopencv_features2d.so.2.4: undefined reference to `cv::AlgorithmInfo::addParam(cv::Algorithm&, char const*, short&, bool, int (cv::Algorithm::)(), void (cv::Algorithm::)(int), std::basic_string, std::allocator > const&)'

//usr/local/lib/libopencv_calib3d.so.2.4: undefined reference to `cv::Mutex::Mutex()'

//usr/local/lib/libopencv_ocl.so.2.4: undefined reference to `cv::TLSDataContainer::TLSDataContainer()'

//usr/local/lib/libopencv_calib3d.so.2.4: undefined reference to `cv::ParallelLoopBody::~ParallelLoopBody()'

//usr/local/lib/libopencv_calib3d.so.2.4: undefined reference to `cv::Mutex::~Mutex()'

//usr/local/lib/libopencv_ocl.so.2.4: undefined reference to `cv::TLSDataContainer::~TLSDataContainer()' collect2: ld returned 1 exit status

最佳答案

您尚未将可执行文件链接到程序所需的多个库

尝试使用这个:

g++ -lpthread `pkg-config opencv --libs` -I/usr/local/include/ -lraspicam -lraspicam_cv -L/opt/vc/lib -lmmal -lmmal_core -lmmal_util -I/usr/include -lwiringPi test3.cpp -o test3 

关于c++ - 使用已编译版本的 openCV 时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30903180/

相关文章:

c++ - 如何在 C++ 中创建临时对象

c++ - 交换整数的代码适用于 C++,但不适用于 C

c++ - 为什么这个变量被标记为 "unused"?

python - 如何使用 python 查找文件中的特定范围?

linux - mongodb错误的成员ID

c++ - CodeBlocks 没有构建我的项目

c - 无法在游戏板上打印 token

c - struct sockaddr,我们真的需要给addrlen吗

c - 如何使用 sscanf 读取括号之间的字符串?

linux - 将所有命令和标准输出记录到文件的别名