环境:Debian 7.5 Wheezy。
我刚刚编译并安装了版本为2.4.9的OpenCV库,并激活了英特尔IPP(集成性能基元)。 我在/ opt / ipp版本8.1 SP 3中安装了IPP。
在cmake期间,它findOK 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)。
它在系统中:$ locate 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/
我怎样才能编译这个,所以海湾合作委员会发现IPP库?
编辑1
我已经尝试创build一个文件/etc/ld.so.conf.d/IntelIPP.conf并在那里添加设置在LD_LIBRARY_PATH中的英特尔IPPpath,重新启动系统并重新编译。 没有效果。
但是,我猜这是: “/ usr / bin / ld:找不到-llibsvml.so”应该表示它正在寻找一个“liblibsvml.so”(ld在库文件名内部足够“lib”认为)。
还有一点要注意: “gcc -ggdb pkg-config --cflags opencv
-o basename $i .c
$ i`pkg-config –libs”只针对opencv执行pkg-config,没有任何IPP被命名。 所以,在编译或者安装的时候,这可能是OpenCV硬编码的一些lib位置。
有关这个的任何线索?
编辑2
按照这个新的方法,我去了〜/ Downloads / 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,并成功安装…没有运气。 现在编译示例给出了相同的错误,但没有“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/中search“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在链接和编译时加载库的文件。
注意这个:
Libs:(…)$ {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,所以这应该工作…任何想法?
解决它自己。
编辑/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库中。