Linux安装opencv3.2.0遇到的一个坑

在尝试使用make-j4编译OpenCV 3.2.0时遇到错误,链接器报告libopencv_core.so.3.2.0中缺少cblas_sgemm等cblas函数的定义。尽管在cmake阶段似乎已经找到并链接了cblas库,但编译仍然失败。为了解决这个问题,建议删除/usr/lib/aarch64-linux-gnu/下的libcblas.a和libcblas.so,然后重新运行cmake、make和make install步骤。经过这个过程,编译最终成功完成,所有目标如cv2.so和opencv_python2都已正确构建。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

[ 63%] Linking CXX executable ../../bin/opencv_visualisation
/usr/bin/ld: ../../lib/libopencv_core.so.3.2.0: undefined reference to `cblas_sgemm(CBLAS_ORDER, CBLAS_TRANSPOSE, CBLAS_TRANSPOSE, int, int, int, float, float const*, int, float const*, int, float, float*, int)'
/usr/bin/ld: ../../lib/libopencv_core.so.3.2.0: undefined reference to `cblas_zgemm(CBLAS_ORDER, CBLAS_TRANSPOSE, CBLAS_TRANSPOSE, int, int, int, void const*, void const*, int, void const*, int, void const*, void*, int)'
/usr/bin/ld: ../../lib/libopencv_core.so.3.2.0: undefined reference to `cblas_dgemm(CBLAS_ORDER, CBLAS_TRANSPOSE, CBLAS_TRANSPOSE, int, int, int, double, double const*, int, double const*, int, double, double*, int)'
/usr/bin/ld: ../../lib/libopencv_core.so.3.2.0: undefined reference to `cblas_cgemm(CBLAS_ORDER, CBLAS_TRANSPOSE, CBLAS_TRANSPOSE, int, int, int, void const*, void const*, int, void const*, int, void const*, void*, int)'
collect2: error: ld returned 1 exit status
make[2]: *** [apps/visualisation/CMakeFiles/opencv_visualisation.dir/build.make:92: bin/opencv_visualisation] Error 1
make[1]: *** [CMakeFiles/Makefile2:7078: apps/visualisation/CMakeFiles/opencv_visualisation.dir/all] Error 2
make: *** [Makefile:163: all] Error 2

在make -j4编译的时候报错,出现编译问题

/usr/bin/ld: …/…/lib/libopencv_core.so.3.2.0: undefined reference to `cblas_sgemm(CBLAS_ORDER, CBLAS_TRANSPOSE, CBLAS_TRANSPOSE, int, int, int, float, float const*, int, float const*, int, float, float*, int)’

提示链接不到这几个cblas函数的定义,但是在cmake …操作的时候是找到了cblas库的(下面倒数第二行)

--     Extra dependencies:          
/usr/lib64/libjpeg.so /usr/lib/aarch64-linux-gnu/libpng.so
 /usr/lib/aarch64-linux-gnu/libz.so 
 /usr/lib/aarch64-linux-gnu
 /libtiff.so gtk-x11-2.0 gdk-x11-2.0 pangocairo-1.0 atk-1.0 cairo gdk_pixbuf-2.0 gio-2.0 pangoft2-1.0 pango-1.0 gobject-2.0 glib-2.0 fontconfig freetype gthread-2.0 dc1394 avcodec avformat avutil swscale avresample dl m pthread rt 
 /usr/lib/aarch64-linux-gnu/liblapack.so 
 /usr/lib/aarch64-linux-gnu/libcblas.so 
 /usr/lib/aarch64-linux-gnu/libatlas.so

解决方法
直接删除libcblas.a和libcblas.so

sudo rm -rf /usr/lib/aarch64-linux-gnu/libcblas.a
sudo rm -rf /usr/lib/aarch64-linux-gnu/libcblas.so

再重新编译安装opencv

cmake ..
make
sudo make install
[100%] Built target opencv_perf_stitching
[100%] Linking CXX shared module ../../lib/cv2.so
[100%] Built target opencv_python2

成功

评论 5
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值