2014-06-20 57 views
0

我使用OpenCV的的Makefile的OpenCV停止工作

CFLAGS = `pkg-config --cflags opencv` 
LIBS = `pkg-config --libs opencv` 

% : %.cpp 
    g++ $(CFLAGS) -o [email protected] $< $(LIBS) 

這工作得很好,直到最近纔有下面的Makefile的項目。我現在得到了以下錯誤:

/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 

pkg-config --libs opencv輸出:

/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 
/usr/lib/x86_64-linux-gnu/libXext.so 
/usr/lib/x86_64-linux-gnu/libX11.so 
/usr/lib/x86_64-linux-gnu/libICE.so 
/usr/lib/x86_64-linux-gnu/libSM.so 
/usr/lib/libGL.so 
/usr/lib/x86_64-linux-gnu/libGLU.so 
-lcufft -lnpps -lnppi -lnppc -lcudart -ltbb -lrt -lpthread -lm -ldl 

我已經出口到LD_LIBRARY_PATH的CUDA庫路徑:

echo $LD_LIBRARY_PATH 
/usr/local/cuda-5.5/lib64 

此路徑確實包含了庫:

ls $LD_LIBRARY_PATH 
libcublas_device.a libcudart.so.5.0  libcufftw.so   libcurand.so.5.5  libnppc.so.5.5.22 libnvToolsExt.so 
libcublas.so   libcudart.so.5.5  libcufftw.so.5.5  libcurand.so.5.5.22 libnppi.so   libnvToolsExt.so.1 
libcublas.so.5.0  libcudart.so.5.5.22 libcufftw.so.5.5.22 libcusparse.so   libnppi.so.5.5  libnvToolsExt.so.1.0.0 
libcublas.so.5.5  libcudart_static.a libcuinj64.so   libcusparse.so.5.5  libnppi.so.5.5.22 
libcublas.so.5.5.22 libcufft.so   libcuinj64.so.5.5  libcusparse.so.5.5.22 libnpps.so 
libcudadevrt.a  libcufft.so.5.5  libcuinj64.so.5.5.22 libnppc.so    libnpps.so.5.5 
libcudart.so   libcufft.so.5.5.22 libcurand.so   libnppc.so.5.5   libnpps.so.5.5.22 

但我仍然得到錯誤。我運行opencv 2.4.9和cuda 5.5。我忘了什麼?

+0

你有沒有嘗試用'-L'在Makefile中添加cuda庫的路徑?也許這裏有一個答案http://stackoverflow.com/questions/1904990/what-is-the-difference-between-ld-library-path-and-l-at-link-time –

+0

我現在做了這個:' g ++ -L/usr/local/cuda-5.5/lib64''pkg-config --cflags opencv'' -o writeFramesMainSimple writeFramesMainSimple.cpp'' pkg-config --libs opencv'它工作正常!儘管如此,我仍然不明白爲什麼它會停止工作,因爲這正是'LD_LIBRARY_PATH'中的內容。根據你的鏈接,這應該很好...... – BdB

回答

0

我現在這樣做:g++ -L /usr/local/cuda-5.5/lib64 pkg-config --cflags opencv -o writeFramesMainSimple writeFramesMainSimple.cpp pkg-config --libs opencv和它的工作!

1

LD_LIBRARY_PATH用於運行時。編譯時需要使用LIBRARY_PATH。 要麼你出口/usr/local/cuda-5.5/lib64LIBRARY_PATH或者您在Makefile中添加路徑LIBS

LIBS += -L/usr/local/cuda-5.5/lib64 

LD_LIBRARY_PATH vs LIBRARY_PATH

+0

我將'/ usr/local/cuda-5.5/lib64'導出到'LIBRARY_PATH'。現在我得到'/ usr/bin/ld:跳過不兼容的/usr/local/cuda-5.5/lib64/../lib/libcufft.so搜索-lcufft /usr/bin/ld:跳過不兼容的/ usr/local/cuda-5.5/lib64 /../ lib/libnpps.so搜索-lnpps /usr/bin/ld:跳過不兼容的/usr/local/cuda-5.5/lib64/../lib/libnppi.so當搜索-lnppi /usr/bin/ld時:跳過不兼容的/usr/local/cuda-5.5/lib64/../lib/libnppc.so/usr/bin/ld:跳過不兼容的/ usr/local/cuda-5.5/lib64 /../ lib/libcudart.so當搜索-lcudart'時 – BdB

+0

http://stackoverflow.com/questions/17080280/skipping-incompatible-libcudart-so-when-searching-for -lcudart –

+0

當我將'/ usr/local/cuda-5.5/lib'導出到'LIBRARY_PATH'時,我得到'/ usr/bin/ld:跳過不兼容的/usr/local/cuda-5.5/lib/../lib /libcufft.so搜索時g爲-lcufft /usr/bin/ld:在搜索-lcufft時跳過不兼容的/usr/local/cuda-5.5/lib/libcufft.so /usr/bin/ld:找不到-lcufft等 – BdB