编译一个opencv程序,链接的时候出现大量的如下错误:
/home/admin/opencv/opencv-master/modules/imgproc/src/color_lab.cpp:23: undefined reference to `cv::s
oftfloat::softfloat(int)‘
softfloat是个什么鬼?应该链接哪个库才行?
vi /home/admin/opencv/opencv-master/modules/imgproc/src/color_lab.cpp
看见源代码里面引用了#include "opencv2/core/softfloat.hpp"
然后softfloat.hpp对应的实现文件是 softfloat.cpp
那么,只要我找到softfloat.cpp被编译到哪个库文件就行了!
于是运行: nm -A lib64/libopencv*.a | grep "softfloat.cpp"
libopencv_core.a:softfloat.cpp.o:0000000000000000 T _ZNK2cv9softfloatmiERKS0_ libopencv_core.a:softfloat.cpp.o:0000000000000000 T _ZNK2cv9softfloatmlERKS0_ libopencv_core.a:softfloat.cpp.o:0000000000000000 T _ZNK2cv9softfloatneERKS0_
原来是在libopencv_core.a中,命令行中已经加上了这个库,看来是依赖顺序的问题。在gcc命令行最后再加上 -lopencv_core,问题解决。
原文地址:https://www.cnblogs.com/ahfuzhang/p/10843181.html
时间: 2024-10-12 22:02:18