g++ 编译cpp程序 /usr/bin/ld: cannot find -lopencv_cudabgsegm....等问题

执行
g++ mtcnn_opencv.cpp -I /usr/local/opencv3.4.0/include -shared -o libmtcnndetection2.so -std=c++11 -fPIC pkg-config opencv --cflags --libs
出现如下问题:
/usr/bin/ld: cannot find -lopencv_cudabgsegm
/usr/bin/ld: cannot find -lopencv_cudaobjdetect
/usr/bin/ld: cannot find -lopencv_cudastereo
/usr/bin/ld: cannot find -lopencv_dnn
/usr/bin/ld: cannot find -lopencv_ml
/usr/bin/ld: cannot find -lopencv_shape
/usr/bin/ld: cannot find -lopencv_stitching
/usr/bin/ld: cannot find -lopencv_cudafeatures2d
/usr/bin/ld: cannot find -lopencv_superres
/usr/bin/ld: cannot find -lopencv_cudacodec
/usr/bin/ld: cannot find -lopencv_videostab
/usr/bin/ld: cannot find -lopencv_cudaoptflow
/usr/bin/ld: cannot find -lopencv_cudalegacy
/usr/bin/ld: cannot find -lopencv_calib3d
/usr/bin/ld: cannot find -lopencv_features2d
/usr/bin/ld: cannot find -lopencv_highgui
/usr/bin/ld: cannot find -lopencv_videoio
/usr/bin/ld: cannot find -lopencv_photo
/usr/bin/ld: cannot find -lopencv_imgcodecs
/usr/bin/ld: cannot find -lopencv_cudawarping
/usr/bin/ld: cannot find -lopencv_cudaimgproc
/usr/bin/ld: cannot find -lopencv_cudafilters
/usr/bin/ld: cannot find -lopencv_video
/usr/bin/ld: cannot find -lopencv_objdetect
/usr/bin/ld: cannot find -lopencv_imgproc
/usr/bin/ld: cannot find -lopencv_flann
/usr/bin/ld: cannot find -lopencv_cudaarithm
/usr/bin/ld: cannot find -lopencv_core
/usr/bin/ld: cannot find -lopencv_cudev
collect2: error: ld returned 1 exit status

第一步解决:
执行
sudo apt-get install libopencv-dev
解决非cuda的问题(/usr/bin/ld: cannot find -lopencv_dnn)除外
/usr/bin/ld: cannot find -lopencv_cudabgsegm
/usr/bin/ld: cannot find -lopencv_cudaobjdetect
/usr/bin/ld: cannot find -lopencv_cudastereo
/usr/bin/ld: cannot find -lopencv_dnn
/usr/bin/ld: cannot find -lopencv_cudafeatures2d
/usr/bin/ld: cannot find -lopencv_cudacodec
/usr/bin/ld: cannot find -lopencv_cudaoptflow
/usr/bin/ld: cannot find -lopencv_cudalegacy
/usr/bin/ld: cannot find -lopencv_cudawarping
/usr/bin/ld: cannot find -lopencv_cudaimgproc
/usr/bin/ld: cannot find -lopencv_cudafilters
/usr/bin/ld: cannot find -lopencv_cudaarithm
/usr/bin/ld: cannot find -lopencv_cudev

第二步解决:
指定库路径 -L指定路径 -L /usr/local/opencv3.4.0/lib
g++ mtcnn_opencv.cpp -I /usr/local/opencv3.4.0/include -L /usr/local/opencv3.4.0/lib -shared -o libmtcnndetection2.so -std=c++ 11 -fPIC pkg-config opencv --cflags --libs

成功生成动态链接库so文件

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 2
    评论
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值