2014-06-15 103 views
3

環境:Debian 7.5 Wheezy。Debian使用IPP編譯OpenCV示例:/ usr/bin/ld:找不到-llibsvml.so collect2:錯誤:ld返回1退出狀態

我剛剛編譯並安裝了版本爲2.4.9的OpenCV庫,並啓動了英特爾IPP(集成性能基元)。我在/ opt/ipp版本8.1 SP 3中安裝了IPP。

在cmake期間,它找到OK IPP庫,並編譯並安裝在/ opt/OpenCV中,沒有任何問題。

當我去到c例子文件夾,還有,編譯所有示例腳本:

$ ls /opt/OpenCV/OpenCV-2.4.9/share/OpenCV/samples/c 
adaptiveskindetector.cpp box_in_scene.png facedetect.cmd   latentsvmdetect.cpp  one_way_train_0001.jpg 
agaricus-lepiota.data  box.png   facedetect.cpp   lena.jpg    polar_transforms.c 
airplane.jpg    build_all.sh  fback_c.c    morphology.c   puzzle.png 
baboon200.jpg    cat.jpg   find_obj_calonder.cpp motempl.c    pyramid_segmentation.c 
baboon200_rotated.jpg  contours.c   find_obj.cpp   mser_sample.cpp   smiledetect.cpp 
baboon.jpg    convert_cascade.c find_obj_ferns.cpp  mushroom.cpp   stuff.jpg 
bgfg_codebook.cpp   cvsample.dsp  fruits.jpg    one_way_sample.cpp  tree_engine.cpp 
blobtrack_sample.cpp  delaunay.c   JCB.png    one_way_train_0000.jpg waveform.data 

現在,讓我們運行腳本:

$ ./build_all.sh 

每個源文件提供一個像這樣的輸出:

compiling tree_engine.cpp 
/usr/bin/ld: cannot find -llibsvml.so 
/usr/bin/ld: cannot find -llibimf.so 
/usr/bin/ld: cannot find -llibirc.so 
/usr/bin/ld: cannot find -llibippcore.a 
/usr/bin/ld: cannot find -llibipps.a 
/usr/bin/ld: cannot find -llibippi.a 
/usr/bin/ld: cannot find -llibippcv.a 
/usr/bin/ld: cannot find -llibippcc.a 
/usr/bin/ld: cannot find -llibippvm.a 
collect2: error: ld returned 1 

內容build_all.sh的:

#!/bin/sh 

if [ $# -gt 0 ] ; then 
    base=`basename $1 .c` 
    echo "compiling $base" 
    gcc -ggdb `pkg-config opencv --cflags --libs` $base.c -o $base 
else 
    for i in *.c; do 
     echo "compiling $i" 
     gcc -ggdb `pkg-config --cflags opencv` -o `basename $i .c` $i `pkg-config --libs opencv`; 
    done 
    for i in *.cpp; do 
     echo "compiling $i" 
     g++ -ggdb `pkg-config --cflags opencv` -o `basename $i .cpp` $i `pkg-config --libs opencv`; 
    done 
fi 

讓我們關注第一個未找到的庫(/ usr/bin/ld:找不到-llibsvml.so)。

它在系統: $定位libsvml.so /opt/intel/composer_xe_2013_sp1.3.174/compiler/lib/ia32/libsvml.so /opt/intel/composer_xe_2013_sp1.3.174/compiler/lib/intel64/ libsvml.so /opt/intel/composer_xe_2013_sp1.3.174/compiler/lib/mic/libsvml.so

它的文件夾是在LD_LIBRARY_PATH:

$ echo $LD_LIBRARY_PATH 
/opt/intel/composer_xe_2013_sp1.3.174/compiler/lib/intel64:/opt/intel/composer_xe_2013_sp1.3.174/mpirt/lib/intel64:/opt/intel/composer_xe_2013_sp1.3.174/compiler/lib/intel64:/opt/intel/composer_xe_2013_sp1.3.174/ipp/lib/intel64:/opt/OpenCV/OpenCV-2.4.9/lib 

在LIBRARY_PATH太:

$ echo $LIBRARY_PATH 
/opt/intel/composer_xe_2013_sp1.3.174/compiler/lib/intel64:/opt/intel/composer_xe_2013_sp1.3.174/ipp/lib/intel64 

就我所見,buildAll腳本依賴於pkg-config來查找庫。引人注目的是,當運行這些命令返回任何結果:

$ pkg-config --list-all | grep ipp 
$ pkg-config --list-all | grep vml 
$ dpkg -l | grep ipp 
$ dpkg -l | grep vml 

哪裏是gcc編譯期間在尋找:

$ gcc --print-search-dirs 
install: /usr/lib/gcc/x86_64-linux-gnu/4.7/ 
programs: =/usr/lib/gcc/x86_64-linux-gnu/4.7/:/usr/lib/gcc/x86_64-linux-gnu/4.7/:/usr/lib/gcc/x86_64-linux-gnu/:/usr/lib/gcc/x86_64-linux-gnu/4.7/:/usr/lib/gcc/x86_64-linux-gnu/:/usr/lib/gcc/x86_64-linux-gnu/4.7/../../../../x86_64-linux-gnu/bin/x86_64-linux-gnu/4.7/:/usr/lib/gcc/x86_64-linux-gnu/4.7/../../../../x86_64-linux-gnu/bin/x86_64-linux-gnu/:/usr/lib/gcc/x86_64-linux-gnu/4.7/../../../../x86_64-linux-gnu/bin/ 
libraries: =/opt/intel/composer_xe_2013_sp1.3.174/compiler/lib/intel64/x86_64-linux-gnu/4.7/:/opt/intel/composer_xe_2013_sp1.3.174/compiler/lib/intel64/x86_64-linux-gnu/:/opt/intel/composer_xe_2013_sp1.3.174/compiler/lib/intel64/../lib/:/opt/intel/composer_xe_2013_sp1.3.174/ipp/lib/intel64/x86_64-linux-gnu/4.7/:/opt/intel/composer_xe_2013_sp1.3.174/ipp/lib/intel64/x86_64-linux-gnu/:/opt/intel/composer_xe_2013_sp1.3.174/ipp/lib/intel64/../lib/:/usr/lib/gcc/x86_64-linux-gnu/4.7/:/usr/lib/gcc/x86_64-linux-gnu/4.7/../../../../x86_64-linux-gnu/lib/x86_64-linux-gnu/4.7/:/usr/lib/gcc/x86_64-linux-gnu/4.7/../../../../x86_64-linux-gnu/lib/x86_64-linux-gnu/:/usr/lib/gcc/x86_64-linux-gnu/4.7/../../../../x86_64-linux-gnu/lib/../lib/:/usr/lib/gcc/x86_64-linux-gnu/4.7/../../../x86_64-linux-gnu/4.7/:/usr/lib/gcc/x86_64-linux-gnu/4.7/../../../x86_64-linux-gnu/:/usr/lib/gcc/x86_64-linux-gnu/4.7/../../../../lib/:/lib/x86_64-linux-gnu/4.7/:/lib/x86_64-linux-gnu/:/lib/../lib/:/usr/lib/x86_64-linux-gnu/4.7/:/usr/lib/x86_64-linux-gnu/:/usr/lib/../lib/:/opt/intel/composer_xe_2013_sp1.3.174/compiler/lib/intel64/:/opt/intel/composer_xe_2013_sp1.3.174/ipp/lib/intel64/:/usr/lib/gcc/x86_64-linux-gnu/4.7/../../../../x86_64-linux-gnu/lib/:/usr/lib/gcc/x86_64-linux-gnu/4.7/../../../:/lib/:/usr/lib/ 

我怎麼編譯這一點,所以GCC發現IPP庫?


編輯1

我試圖創建一個文件/etc/ld.so.conf.d/IntelIPP.conf並添加那裏LD_LIBRARY_PATH英特爾IPP設定的路徑,重啓系統並重新編譯。沒有效果。

不過,我猜一下:「在/ usr /斌/勞工處:找不到-llibsvml.so」應該意味着它在尋找一個「liblibsvml.so」(LD足夠了「LIB」內部到庫文件名,我認爲)。

還有一點要注意:「GCC -ggdb pkg-config --cflags opencv -o basename $i .c $`我pkg配置--libs」執行pkg配置只針對OpenCV的,沒有IPP被命名的。所以,它可能是一些在編譯或安裝過程中由OpenCV硬編碼的lib位置。

有關這方面的任何線索?


EDIT 2

按照這種新的方法,我已經到〜/下載/ openscv-2.4.9/cmake的/ OpenCVFindIPP.cmake和改變:

# ------------------------------------------------------------------------ 
# This is auxiliary function called from set_ipp_variables() 
# to set IPP_LIBRARIES variable in IPP 7.x and 8.x style 
# ------------------------------------------------------------------------ 
function(set_ipp_new_libraries _LATEST_VERSION) 
    set(IPP_PREFIX "ipp") 

    if(${_LATEST_VERSION} VERSION_LESS "8.0") 
     set(IPP_SUFFIX "_l")  # static not threaded libs suffix IPP 7.x 
    else() 
     if(WIN32) 
      set(IPP_SUFFIX "mt") # static not threaded libs suffix IPP 8.x for Windows 
     else() 
      set(IPP_SUFFIX "")  # static not threaded libs suffix IPP 8.x for Linux/OS X 
     endif() 
    endif() 
    set(IPPCORE "core")  # core functionality 
    set(IPPSP  "s")  # signal processing 
    set(IPPIP  "i")  # image processing 
    set(IPPCC  "cc")  # color conversion 
    set(IPPCV  "cv")  # computer vision 
    set(IPPVM  "vm")  # vector math 

    set(IPP_LIBRARIES 
     ${IPP_PREFIX}${IPPVM}${IPP_SUFFIX}${IPP_LIB_SUFFIX} 
     ${IPP_PREFIX}${IPPCC}${IPP_SUFFIX}${IPP_LIB_SUFFIX} 
     ${IPP_PREFIX}${IPPCV}${IPP_SUFFIX}${IPP_LIB_SUFFIX} 
     ${IPP_PREFIX}${IPPI}${IPP_SUFFIX}${IPP_LIB_SUFFIX} 
     ${IPP_PREFIX}${IPPS}${IPP_SUFFIX}${IPP_LIB_SUFFIX} 
     ${IPP_PREFIX}${IPPCORE}${IPP_SUFFIX}${IPP_LIB_SUFFIX}) 

    if (UNIX) 
     set(IPP_LIBRARIES 
      ${IPP_LIBRARIES} 
      irc${CMAKE_SHARED_LIBRARY_SUFFIX} 
      imf${CMAKE_SHARED_LIBRARY_SUFFIX} 
      svml${CMAKE_SHARED_LIBRARY_SUFFIX}) 
    endif() 
    set(IPP_LIBRARIES ${IPP_LIBRARIES} PARENT_SCOPE) 
    return() 

endfunction() 

通過:

# ------------------------------------------------------------------------ 
# This is auxiliary function called from set_ipp_variables() 
# to set IPP_LIBRARIES variable in IPP 7.x and 8.x style 
# ------------------------------------------------------------------------ 
function(set_ipp_new_libraries _LATEST_VERSION) 
    set(IPP_PREFIX "ipp") 

    if(${_LATEST_VERSION} VERSION_LESS "8.0") 
     set(IPP_SUFFIX "_l")  # static not threaded libs suffix IPP 7.x 
    else() 
     if(WIN32) 
      set(IPP_SUFFIX "mt") # static not threaded libs suffix IPP 8.x for Windows 
     else() 
      set(IPP_SUFFIX "")  # static not threaded libs suffix IPP 8.x for Linux/OS X 
     endif() 
    endif() 
    set(IPPCORE "core")  # core functionality 
    set(IPPSP  "s")  # signal processing 
    set(IPPIP  "i")  # image processing 
    set(IPPCC  "cc")  # color conversion 
    set(IPPCV  "cv")  # computer vision 
    set(IPPVM  "vm")  # vector math 

    set(IPP_LIBRARIES 
     ${IPP_LIB_PREFIX}${IPP_PREFIX}${IPPVM}${IPP_SUFFIX}${IPP_LIB_SUFFIX} 
     ${IPP_LIB_PREFIX}${IPP_PREFIX}${IPPCC}${IPP_SUFFIX}${IPP_LIB_SUFFIX} 
     ${IPP_LIB_PREFIX}${IPP_PREFIX}${IPPCV}${IPP_SUFFIX}${IPP_LIB_SUFFIX} 
     ${IPP_LIB_PREFIX}${IPP_PREFIX}${IPPI}${IPP_SUFFIX}${IPP_LIB_SUFFIX} 
     ${IPP_LIB_PREFIX}${IPP_PREFIX}${IPPS}${IPP_SUFFIX}${IPP_LIB_SUFFIX} 
     ${IPP_LIB_PREFIX}${IPP_PREFIX}${IPPCORE}${IPP_SUFFIX}${IPP_LIB_SUFFIX}) 

    if (UNIX) 
     set(IPP_LIBRARIES 
      ${IPP_LIBRARIES} 
      ${IPP_LIB_PREFIX}irc${CMAKE_SHARED_LIBRARY_SUFFIX} 
      ${IPP_LIB_PREFIX}imf${CMAKE_SHARED_LIBRARY_SUFFIX} 
      ${IPP_LIB_PREFIX}svml${CMAKE_SHARED_LIBRARY_SUFFIX}) 
    endif() 
    set(IPP_LIBRARIES ${IPP_LIBRARIES} PARENT_SCOPE) 
    return() 

endfunction() 

重新編譯OpenCV並使安裝成功... wi沒有運氣。編譯例子現在給同樣的錯誤,但沒有 「LIB」:

compiling tree_engine.cpp 
/usr/bin/ld: cannot find -lsvml.so 
/usr/bin/ld: cannot find -limf.so 
/usr/bin/ld: cannot find -lirc.so 
/usr/bin/ld: cannot find -lippcore.a 
/usr/bin/ld: cannot find -lipps.a 
/usr/bin/ld: cannot find -lippi.a 
/usr/bin/ld: cannot find -lippcv.a 
/usr/bin/ld: cannot find -lippcc.a 
/usr/bin/ld: cannot find -lippvm.a 
collect2: error: ld returned 1 exit status 

編輯3

另一種方法:在/opt/OpenCV/OpenCV-2.4.9/搜索 「svml」。

這會導致2個文件。

/opt/OpenCV/OpenCV-2.4.9/share/OpenCV/OpenCVModules-debug.cmake:示

# Import target "opencv_ts" for configuration "Debug" 
SET_PROPERTY(TARGET opencv_ts APPEND PROPERTY IMPORTED_CONFIGURATIONS DEBUG) 
SET_TARGET_PROPERTIES(opencv_ts PROPERTIES 
    IMPORTED_LINK_INTERFACE_LANGUAGES_DEBUG "CXX" 
    IMPORTED_LINK_INTERFACE_LIBRARIES_DEBUG "opencv_core;opencv_flann;opencv_imgproc;opencv_highgui;opencv_features2d;dl;m;pthread;rt;/usr/lib/x86_64-linux-gnu/libGLU.so;/usr/lib/x86_64-linux-gnu/libGL.so;/usr/lib/x86_64-linux-gnu/libSM.so;/usr/lib/x86_64-linux-gnu/libICE.so;/usr/lib/x86_64-linux-gnu/libX11.so;/usr/lib/x86_64-linux-gnu/libXext.so;tbb;libippvm.a;libippcc.a;libippcv.a;libippi.a;libipps.a;libippcore.a;libirc.so;libimf.so;libsvml.so" 
    IMPORTED_LOCATION_DEBUG "${_IMPORT_PREFIX}/lib/libopencv_ts.a" 
) 

LIST(APPEND _IMPORT_CHECK_TARGETS opencv_ts) 
LIST(APPEND _IMPORT_CHECK_FILES_FOR_opencv_ts "${_IMPORT_PREFIX}/lib/libopencv_ts.a") 

只有線路211〜220。不知道是什麼,這些線路的真正含義。

/opt/OpenCV/OpenCV-2.4.9/lib/pkgconfig/opencv.pc

# Package Information for pkg-config 

prefix=/opt/OpenCV/OpenCV-2.4.9 
exec_prefix=${prefix} 
libdir= 
includedir_old=${prefix}/include/opencv 
includedir_new=${prefix}/include 

Name: OpenCV 
Description: Open Source Computer Vision Library 
Version: 2.4.9 
Libs: ${exec_prefix}/lib/libopencv_calib3d.so ${exec_prefix}/lib/libopencv_contrib.so ${exec_prefix}/lib/libopencv_core.so ${exec_prefix}/lib/libopencv_features2d.so ${exec_prefix}/lib/libopencv_flann.so ${exec_prefix}/lib/libopencv_gpu.so ${exec_prefix}/lib/libopencv_highgui.so ${exec_prefix}/lib/libopencv_imgproc.so ${exec_prefix}/lib/libopencv_legacy.so ${exec_prefix}/lib/libopencv_ml.so ${exec_prefix}/lib/libopencv_nonfree.so ${exec_prefix}/lib/libopencv_objdetect.so ${exec_prefix}/lib/libopencv_ocl.so ${exec_prefix}/lib/libopencv_photo.so ${exec_prefix}/lib/libopencv_stitching.so ${exec_prefix}/lib/libopencv_superres.so ${exec_prefix}/lib/libopencv_ts.a ${exec_prefix}/lib/libopencv_video.so ${exec_prefix}/lib/libopencv_videostab.so ${exec_prefix}/lib/libopencv_viz.so -llibsvml.so -llibimf.so -llibirc.so -llibippcore.a -llibipps.a -llibippi.a -llibippcv.a -llibippcc.a -llibippvm.a -ltbb /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/x86_64-linux-gnu/libGL.so /usr/lib/x86_64-linux-gnu/libGLU.so -lrt -lpthread -lm -ldl 
Cflags: -I${includedir_old} -I${includedir_new} 

我認爲這個文件是非常有趣的一個,據我所知,這是由所使用的文件pkg-config和ld在鏈接和編譯時加載庫。

注意這一點:

利布斯:(...)$ {exec_prefix} /lib/libopencv_viz.so -llibsvml.so -llibimf.so -llibirc.so -llibippcore.a -llibipps.a - llibippi.a -llibippcv.a -llibippcc.a -llibippvm.a -ltbb /usr/lib/x86_64-linux-gnu/libXext.so(..)

我仍然不確定該怎麼做。 .. -l [xxx]應該從LD_LIBRARY_PATH加載xxx,所以這應該工作...任何想法?

回答

2

自己解決了。

編輯/opt/OpenCV/OpenCV-2.4.9/lib/pkgconfig/opencv.pc,並把這個:

# Package Information for pkg-config 

prefix=/opt/OpenCV/OpenCV-2.4.9 
exec_prefix=${prefix} 
libdir= 
includedir_old=${prefix}/include/opencv 
includedir_new=${prefix}/include 

#RLP 16-06-14: For Intel IPP 8.1 
IntelIPPCompilerLib=/opt/intel/composer_xe_2013_sp1.3.174/compiler/lib/intel64 
IntelIPPIPPLib=/opt/intel/composer_xe_2013_sp1.3.174/ipp/lib/intel64 
#RLP'end 

Name: OpenCV 
Description: Open Source Computer Vision Library 
Version: 2.4.9 
#RLP 16-06-14: For Intel IPP 8.1 
#Libs: ${exec_prefix}/lib/libopencv_calib3d.so ${exec_prefix}/lib/libopencv_contrib.so ${exec_prefix}/lib/libopencv_core.so ${exec_prefix}/lib/libopencv_features2d.so ${exec_prefix}/lib/libopencv_flann.so ${exec_prefix}/lib/libopencv_gpu.so ${exec_prefix}/lib/libopencv_highgui.so ${exec_prefix}/lib/libopencv_imgproc.so ${exec_prefix}/lib/libopencv_legacy.so ${exec_prefix}/lib/libopencv_ml.so ${exec_prefix}/lib/libopencv_nonfree.so ${exec_prefix}/lib/libopencv_objdetect.so ${exec_prefix}/lib/libopencv_ocl.so ${exec_prefix}/lib/libopencv_photo.so ${exec_prefix}/lib/libopencv_stitching.so ${exec_prefix}/lib/libopencv_superres.so ${exec_prefix}/lib/libopencv_ts.a ${exec_prefix}/lib/libopencv_video.so ${exec_prefix}/lib/libopencv_videostab.so ${exec_prefix}/lib/libopencv_viz.so -llibsvml.so -llibimf.so -llibirc.so -llibippcore.a -llibipps.a -llibippi.a -llibippcv.a -llibippcc.a -llibippvm.a -ltbb /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/x86_64-linux-gnu/libGL.so /usr/lib/x86_64-linux-gnu/libGLU.so -lrt -lpthread -lm -ldl 
Libs: ${exec_prefix}/lib/libopencv_calib3d.so ${exec_prefix}/lib/libopencv_contrib.so ${exec_prefix}/lib/libopencv_core.so ${exec_prefix}/lib/libopencv_features2d.so ${exec_prefix}/lib/libopencv_flann.so ${exec_prefix}/lib/libopencv_gpu.so ${exec_prefix}/lib/libopencv_highgui.so ${exec_prefix}/lib/libopencv_imgproc.so ${exec_prefix}/lib/libopencv_legacy.so ${exec_prefix}/lib/libopencv_ml.so ${exec_prefix}/lib/libopencv_nonfree.so ${exec_prefix}/lib/libopencv_objdetect.so ${exec_prefix}/lib/libopencv_ocl.so ${exec_prefix}/lib/libopencv_photo.so ${exec_prefix}/lib/libopencv_stitching.so ${exec_prefix}/lib/libopencv_superres.so ${exec_prefix}/lib/libopencv_ts.a ${exec_prefix}/lib/libopencv_video.so ${exec_prefix}/lib/libopencv_videostab.so ${exec_prefix}/lib/libopencv_viz.so ${IntelIPPCompilerLib}/libsvml.so ${IntelIPPCompilerLib}/libimf.so ${IntelIPPCompilerLib}/libirc.so ${IntelIPPIPPLib}/libippcore.a ${IntelIPPIPPLib}/libipps.a ${IntelIPPIPPLib}/libippi.a ${IntelIPPIPPLib}/libippcv.a ${IntelIPPIPPLib}/libippcc.a ${IntelIPPIPPLib}/libippvm.a -ltbb /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/x86_64-linux-gnu/libGL.so /usr/lib/x86_64-linux-gnu/libGLU.so -lrt -lpthread -lm -ldl 
#RLP'end 
Cflags: -I${includedir_old} -I${includedir_new} 

而現在的系統不抱怨這個庫。

讓我感到驚訝的是,在Libs部分,我嘗試使用幾個組合的樣式-L + -l而沒有成功。 (例如:-L/opt/intel/composer_xe_2013_sp1.3。174/compiler/lib/intel64 -llibsmvl.so(和-svml))。

所以我決定直接把文件夾路徑放到IPP庫中。

+0

非常有幫助!謝謝! – mining

相關問題