Hi everyone,<br><br>I'm using cmake to try and Build the latest release of OpenCV (2.3), but am encountering an error. It's important to know that this is on a shared cluster machine where I don't have root access. I've therefore built and installed a few libraries (ffmpeg for example) locally. I'm trying to use these libraries (which, unlike the system installed versions, have both static and shared libraries built) in my opencv build. Somehow /usr/local/lib is creeping into my build and causing problems... I haven't specified that path anywhere and it's not in my PATH/LD_LIBRARY_PATH environment variables:<br>
<br><span style="font-family: courier new,monospace;">PATH=[trimmed]/farrell/bin:/u/vis/software/bin:/usr/local/bin:/usr/bin:/bin:/usr/X11/bin</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">LD_LIBRARY_PATH=/u/vis/software/lib:/usr/lib64:/usr/lib</span><br style="font-family: courier new,monospace;">
<br><br><br>So, here's the command that I'm using to configure with cmake and the output it produces (trimmed in a few places for brevity). Cmake seems to find the ffmpeg libraries fine (in particular, libavcodec which is the one it dies on when building). Note that /usr/local/lib is also producing some troublesome warnings about hiding the correct libraries in /usr/lib64...<br>
<br><br><font face="courier new,monospace">farrell@banana2:/u/vis/software/dist/OpenCV-2.3.0/release> cmake -DCMAKE_BUILD_TYPE=RELEASE -DBUILD_PYTHON_SUPPORT=1 -DCMAKE_INSTALL_PREFIX=/u/vis/software -DCMAKE_VERBOSE=1 -DCMAKE_BUILD_WITH_INSTALL_RPATH=1 ..<br>
-- The C compiler identification is GNU<br>-- The CXX compiler identification is GNU<br>-- Check for working C compiler: /usr/bin/gcc<br>-- Check for working C compiler: /usr/bin/gcc -- works<br>-- Detecting C compiler ABI info<br>
-- Detecting C compiler ABI info - done<br>-- Check for working CXX compiler: /usr/bin/c++<br>-- Check for working CXX compiler: /usr/bin/c++ -- works<br>-- Detecting CXX compiler ABI info<br>-- Detecting CXX compiler ABI info - done<br>
-- Extracting svn version, please wait...<br>-- SVNVERSION: <br>-- Detected version of GNU GCC: 41 (401)<br><br>...<br><br>-- package 'gstreamer-video-0.10' not found<br><b>-- checking for module 'libavcodec'<br>
-- found libavcodec, version 52.20.0<br></b>-- checking for module 'libavformat'<br>-- found libavformat, version 52.31.0<br>-- checking for module 'libavutil'<br>-- found libavutil, version 49.15.0<br>
-- checking for module 'libswscale'<br>-- found libswscale, version 0.7.1<br>-- Looking for libavformat/avformat.h<br>-- Looking for libavformat/avformat.h - found<br>-- Looking for ffmpeg/avformat.h<br>-- Looking for ffmpeg/avformat.h - not found<br>
-- checking for module 'libdc1394-2'<br><br>...<br><br>-- Parsing 'cvconfig.h.cmake'<br>-- GRFMT: /usr/lib64/libz.so;/usr/lib64/libjpeg.so;/usr/lib64/libpng.so;/usr/lib64/libz.so;/usr/lib64/libtiff.so;libjasper<br>
-- HIGHGUI_LIBS: gthread-2.0;rt;glib-2.0;avcodec;avformat;avutil;swscale;/usr/lib64/libbz2.so<br>-- OPENCV_LIBS: dl;m;pthread;rt<br>-- <br>-- General configuration for opencv 2.3.0 =====================================<br>
-- <br>-- Built as dynamic libs?: ON<br>-- Compiler: <br>-- C++ flags (Release): -Wall -Wno-long-long -pthread -ffunction-sections -O3 -DNDEBUG -fomit-frame-pointer -ffast-math -msse -msse2 -DNDEBUG <br>
-- C++ flags (Debug): -Wall -Wno-long-long -pthread -ffunction-sections -g -O0 -DDEBUG -D_DEBUG -ggdb3 <br>-- Linker flags (Release): <br>-- Linker flags (Debug): <br>-- <br><br>...<br>
<br>-- <br>-- Video I/O: <br>-- DC1394 1.x: 0<br>-- DC1394 2.x: 0<br><b>-- FFMPEG: 1<br>-- codec: 1<br></b>-- format: 1<br>
-- util: 1<br>-- swscale: 1<br>-- gentoo-style: 1<br>-- GStreamer: 0<br>-- UniCap: FALSE<br>-- PvAPI: <br>
-- V4L/V4L2: /<br>-- Xine: FALSE<br>-- <br><br>...<br><br>-- Documentation: <br>-- Build Documentation: NO<br>-- <br>-- Install path: /u/vis/software<br>
-- <br>-- cvconfig.h is in: /u/vis/software/dist/OpenCV-2.3.0/release<br>-- -----------------------------------------------------------------<br>-- <br>-- Configuring done<br>CMake Warning at modules/highgui/CMakeLists.txt:259 (add_library):<br>
Cannot generate a safe linker search path for target opencv_highgui because<br> files in some directories may conflict with libraries in implicit<br> directories:<br><br> link library [libz.so] in <b>/usr/lib64</b> may be hidden by files in:<br>
<b>/usr/local/lib<br></b> link library [libtiff.so] in <b>/usr/lib64</b> may be hidden by files in:<br> <b>/usr/local/lib<br><br></b> Some of these libraries may not be found correctly.<br><br><br>CMake Warning at modules/highgui/CMakeLists.txt:259 (add_library):<br>
Cannot generate a safe runtime search path for target opencv_highgui<br> because files in some directories may conflict with libraries in implicit<br> directories:<br><br> runtime library [libz.so.1] in /usr/lib64 may be hidden by files in:<br>
/usr/local/lib<br> runtime library [libtiff.so.3] in /usr/lib64 may be hidden by files in:<br> /usr/local/lib<br><br> Some of these libraries may not be found correctly.<br><br><br>CMake Warning at modules/highgui/CMakeLists.txt:399 (add_executable):<br>
Cannot generate a safe linker search path for target opencv_test_highgui<br> because files in some directories may conflict with libraries in implicit<br> directories:<br><br> link library [libz.so] in /usr/lib64 may be hidden by files in:<br>
/usr/local/lib<br><br> Some of these libraries may not be found correctly.<br><br><br>CMake Warning at modules/highgui/CMakeLists.txt:399 (add_executable):<br> Cannot generate a safe runtime search path for target opencv_test_highgui<br>
because files in some directories may conflict with libraries in implicit<br> directories:<br><br> runtime library [libz.so.1] in /usr/lib64 may be hidden by files in:<br> /usr/local/lib<br><br> Some of these libraries may not be found correctly.<br>
<br><br>-- Generating done<br>CMake Warning:<br> Manually-specified variables were not used by the project:<br><br> BUILD_PYTHON_SUPPORT<br><br><br>-- Build files have been written to: /u/vis/software/dist/OpenCV-2.3.0/release<br>
<br><br><br><br style="font-family: times new roman,serif;"><span style="font-family: times new roman,serif;">Then, when I run the build, I get the error below, showing that the "</span></font><font face="courier new,monospace">-L/usr/local/lib</font><font face="courier new,monospace"><span style="font-family: times new roman,serif;">" is causing the problem, clearly taking precedence over the rpath "</span></font><font face="courier new,monospace">-Wl,-rpath,/u/vis/software/lib:/usr/local/lib</font><font face="courier new,monospace"><span style="font-family: times new roman,serif;">".<br>
<br></span><br style="font-family: times new roman,serif;"><br>Linking CXX shared library ../../lib/libopencv_highgui.so<br>/usr/bin/c++ -fPIC -Wall -Wno-long-long -pthread -ffunction-sections -O3 -DNDEBUG -fomit-frame-pointer -ffast-math -msse -msse2 -DNDEBUG -shared -Wl,-soname,libopencv_highgui.so.2.3 -o ../../lib/libopencv_highgui.so.2.3.0 CMakeFiles/opencv_highgui.dir/src/cap.o CMakeFiles/opencv_highgui.dir/src/cap_images.o CMakeFiles/opencv_highgui.dir/src/cap_ffmpeg.o CMakeFiles/opencv_highgui.dir/src/loadsave.o CMakeFiles/opencv_highgui.dir/src/precomp.o CMakeFiles/opencv_highgui.dir/src/utils.o CMakeFiles/opencv_highgui.dir/src/window.o CMakeFiles/opencv_highgui.dir/src/bitstrm.o CMakeFiles/opencv_highgui.dir/src/grfmt_exr.o CMakeFiles/opencv_highgui.dir/src/grfmt_tiff.o CMakeFiles/opencv_highgui.dir/src/grfmt_jpeg2000.o CMakeFiles/opencv_highgui.dir/src/grfmt_bmp.o CMakeFiles/opencv_highgui.dir/src/grfmt_imageio.o CMakeFiles/opencv_highgui.dir/src/grfmt_png.o CMakeFiles/opencv_highgui.dir/src/grfmt_sunras.o CMakeFiles/opencv_highgui.dir/src/grfmt_base.o CMakeFiles/opencv_highgui.dir/src/grfmt_pxm.o CMakeFiles/opencv_highgui.dir/src/grfmt_jpeg.o <b>-L/usr/local/lib</b> -ldl -lm -lpthread -lrt ../../lib/libopencv_core.so.2.3.0 ../../lib/libopencv_imgproc.so.2.3.0 -lz -ljpeg -lpng -lz -ltiff ../../3rdparty/lib/liblibjasper.a -lgthread-2.0 -lrt -lglib-2.0 -lavcodec -lavformat -lavutil -lswscale -lbz2 ../../lib/libopencv_core.so.2.3.0 -ldl -lm -lpthread -lz -lrt <b>-Wl,-rpath,/u/vis/software/lib:/usr/local/lib </b><br>
/usr/bin/ld: skipping incompatible /usr/local/lib/libz.so when searching for -lz<br>/usr/bin/ld: skipping incompatible /usr/local/lib/libz.a when searching for -lz<br>/usr/bin/ld: skipping incompatible /usr/local/lib/libz.so when searching for -lz<br>
/usr/bin/ld: skipping incompatible /usr/local/lib/libz.a when searching for -lz<br>/usr/bin/ld: skipping incompatible /usr/local/lib/libtiff.so when searching for -ltiff<br>/usr/bin/ld: skipping incompatible /usr/local/lib/libtiff.a when searching for -ltiff<br>
/usr/bin/ld: skipping incompatible /usr/local/lib/<a href="http://libgthread-2.0.so">libgthread-2.0.so</a> when searching for -lgthread-2.0<br>/usr/bin/ld: skipping incompatible /usr/local/lib/<a href="http://libglib-2.0.so">libglib-2.0.so</a> when searching for -lglib-2.0<br>
/usr/bin/ld: skipping incompatible /usr/local/lib/libavcodec.a when searching for -lavcodec<br>/usr/bin/ld: skipping incompatible /usr/local/lib/libavcodec.a when searching for -lavcodec<br>/usr/bin/ld: cannot find -lavcodec<br>
collect2: ld returned 1 exit status<br>make[2]: *** [lib/libopencv_highgui.so.2.3.0] Error 1<br>make[1]: *** [modules/highgui/CMakeFiles/opencv_highgui.dir/all] Error 2<br>make: *** [all] Error 2<br><br><br></font>So, my question is how do I get rid of "/usr/local/lib", in partiuclar the "-L/usr/local/lib"? I'd also love to get rid of the warnings that hint that for these other libs, the /usr/lib64 versions are getting overshadowed by /usr/local/lib versions.<br>
<br>Thanks in advance!<br>Ryan<br><font face="courier new,monospace"><br></font>