红联Linux门户
Linux帮助

ubuntu找不到库编译问题的解决

发布时间:2015-09-07 22:08:31来源:linux网站作者:wlwchina

出现的问题:
g++ -O3 -Wno-unused-result -fopenmp -msse2 XXX.o main.o -o main
/usr/local/lib/libopencv_calib3d.so /usr/local/lib/libopencv_contrib.so
/usr/local/lib/libopencv_core.so /usr/local/lib/libopencv_features2d.so
/usr/local/lib/libopencv_flann.so /usr/local/lib/libopencv_gpu.so
/usr/local/lib/libopencv_highgui.so /usr/local/lib/libopencv_imgproc.so
/usr/local/lib/libopencv_legacy.so /usr/local/lib/libopencv_ml.so
/usr/local/lib/libopencv_nonfree.so /usr/local/lib/libopencv_objdetect.so
/usr/local/lib/libopencv_ocl.so /usr/local/lib/libopencv_photo.so
/usr/local/lib/libopencv_stitching.so /usr/local/lib/libopencv_superres.so
/usr/local/lib/libopencv_ts.a /usr/local/lib/libopencv_video.so
/usr/local/lib/libopencv_videostab.so -lcufft -lnpps -lnppi -lnppc
-lcudart -lrt -lpthread -lm -ldl -L./SDK/lib -lfacesdk -lfinancepro
./SDK/lib/libfw_cv.a
/usr/bin/ld: cannot find -lcufft
/usr/bin/ld: cannot find -lnpps
/usr/bin/ld: cannot find -lnppi
/usr/bin/ld: cannot find -lnppc
/usr/bin/ld: cannot find -lcudart


原因是我机器装了cuda,所以opencv是带cuda模块的,Makefile的LIBS := $(shell pkg-config –libs opencv)会自动连接
-lcufft -lnpps -lnppi -lnppc -lcudart,但是这些库并没有放到默认库目录。
我查了一下cuda的库在 -L/usr/local/cuda-7.0/lib64,所以可以在Makefile中加入:
LIBS+= -L/usr/local/cuda-7.0/lib64


或者
在/etc/ld.so.conf中加入一行:
/usr/local/cuda-7.0/lib64
然后,sudo ldconfig即可。


Ubuntu下的Qt库编译和环境变量设置:http://www.linuxdiyf.com/linux/1154.html