LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Slackware (http://www.linuxquestions.org/questions/slackware-14/)
-   -   Problem building openCV 2.4.0 on 13.37 (http://www.linuxquestions.org/questions/slackware-14/problem-building-opencv-2-4-0-on-13-37-a-4175442606/)

Z038 12-22-2012 06:28 PM

Problem building openCV 2.4.0 on 13.37
 
I'm having a problem building openCV 2.4.0 on 13.37. There are warnings issued for libopenjpeg and libx264.

Code:

cd /mnt/bk/buildtmp/SBo/OpenCV-2.4.0/build/modules/core && /usr/bin/cmake -E cmake_link_script CMakeFiles/opencv_perf_core.dir/link.txt --verbose=1
/usr/bin/c++  -O2 -march=i486 -mtune=i686  -Wall -pthread -march=i686 -fomit-frame-pointer -msse -msse2 -mfpmath=sse -ffunction-sections -O3 -DNDEBUG  -DNDEBUG      CMakeFiles/opencv_perf_core.dir/perf/perf_convertTo.cpp.o CMakeFiles/opencv_perf_core.dir/perf/perf_main.cpp.o CMakeFiles/opencv_perf_core.dir/perf/perf_dft.cpp.o CMakeFiles/opencv_perf_core.dir/perf/perf_precomp.cpp.o CMakeFiles/opencv_perf_core.dir/perf/perf_abs.cpp.o CMakeFiles/opencv_perf_core.dir/perf/perf_dot.cpp.o CMakeFiles/opencv_perf_core.dir/perf/perf_arithm.cpp.o CMakeFiles/opencv_perf_core.dir/perf/perf_split.cpp.o CMakeFiles/opencv_perf_core.dir/perf/perf_bitwise.cpp.o CMakeFiles/opencv_perf_core.dir/perf/perf_minmaxloc.cpp.o CMakeFiles/opencv_perf_core.dir/perf/perf_norm.cpp.o CMakeFiles/opencv_perf_core.dir/perf/perf_math.cpp.o CMakeFiles/opencv_perf_core.dir/perf/perf_merge.cpp.o CMakeFiles/opencv_perf_core.dir/perf/perf_reduce.cpp.o CMakeFiles/opencv_perf_core.dir/perf/perf_stat.cpp.o CMakeFiles/opencv_perf_core.dir/perf/perf_compare.cpp.o  -o ../../bin/opencv_perf_core -rdynamic ../../lib/libopencv_core.so.2.4.0 ../../lib/libopencv_ts.so.2.4.0 ../../lib/libopencv_highgui.so.2.4.0 -ldl -lm -lpthread -lrt ../../lib/libopencv_core.so.2.4.0 -lz -ldl -lm -lpthread -lrt -Wl,-rpath,/mnt/bk/buildtmp/SBo/OpenCV-2.4.0/build/lib -Wl,-rpath-link,/mnt/bk/buildtmp/SBo/OpenCV-2.4.0/build/lib
/usr/lib/gcc/i486-slackware-linux/4.5.2/../../../../i486-slackware-linux/bin/ld: warning: libopenjpeg.so.1.3, needed by /usr/lib/libavcodec.so.52, not found (try using -rpath or -rpath-link)
/usr/lib/gcc/i486-slackware-linux/4.5.2/../../../../i486-slackware-linux/bin/ld: warning: libx264.so.67, needed by /usr/lib/libavcodec.so.52, not found (try using -rpath or -rpath-link)

/usr/lib/libavcodec.so.52: undefined reference to `x264_encoder_close'
/usr/lib/libavcodec.so.52: undefined reference to `x264_encoder_headers'
/usr/lib/libavcodec.so.52: undefined reference to `opj_setup_decoder'
/usr/lib/libavcodec.so.52: undefined reference to `x264_encoder_encode'
/usr/lib/libavcodec.so.52: undefined reference to `x264_encoder_open'
/usr/lib/libavcodec.so.52: undefined reference to `opj_image_destroy'
/usr/lib/libavcodec.so.52: undefined reference to `opj_cio_open'
/usr/lib/libavcodec.so.52: undefined reference to `opj_decode_with_info'
/usr/lib/libavcodec.so.52: undefined reference to `opj_set_event_mgr'
/usr/lib/libavcodec.so.52: undefined reference to `x264_nal_encode'
/usr/lib/libavcodec.so.52: undefined reference to `x264_param_default'
/usr/lib/libavcodec.so.52: undefined reference to `opj_set_default_decoder_parameters'
/usr/lib/libavcodec.so.52: undefined reference to `opj_destroy_decompress'
/usr/lib/libavcodec.so.52: undefined reference to `opj_cio_close'
/usr/lib/libavcodec.so.52: undefined reference to `opj_create_decompress'
collect2: ld returned 1 exit status
make[2]: *** [bin/opencv_perf_core] Error 1
make[2]: Leaving directory `/mnt/bk/buildtmp/SBo/OpenCV-2.4.0/build'
make[1]: *** [modules/core/CMakeFiles/opencv_perf_core.dir/all] Error 2
make[1]: Leaving directory `/mnt/bk/buildtmp/SBo/OpenCV-2.4.0/build'
make: *** [all] Error 2

It says that libavcodec.so.52 needs libopenjpeg.so.1.3 and libx264.so.67.

What I have installed is the following:

Code:

$ ls -al /usr/lib/libopenjpeg.so
lrwxrwxrwx 1 root root 18 Dec 22 12:45 /usr/lib/libopenjpeg.so -> libopenjpeg.so.1.4*
$
$ ls -al /usr/lib/libx264.so
lrwxrwxrwx 1 root root 14 Dec 22 12:09 /usr/lib/libx264.so -> libx264.so.118*

I'm trying to install opencv so it can be linked with ffmpeg 0.8.7. ffmpeg includes libavcodec. Is the problem that the version of libavcodec I have from my previous install of ffmpeg several years ago is too old to link in with opencv?

Can anyone suggest how might I resolve this?

willysr 12-22-2012 06:37 PM

try with newer ffmpeg available on AlienBOB's repository

Z038 12-22-2012 11:04 PM

I'm planning on installing ffmpeg 0.8.7 from slackbuilds.org, and including opencv in the build, as described on the slackbuilds.org page for ffmpeg. It says:

Code:

You can enable a lot of optional (not-autodetected) features by
passing variables to the script (VAR=yes/no ./ffmpeg.SlackBuild):
CELT=yes|no (default: no), requires celt
DC1394=yes|no (default: no), requires libdc1394
DIRAC=yes|no (default: no), requires dirac
FAAC=yes|no (default: no), requires faac (creates non-redistributable binary)
FREI0R=yes|no (default: no), requires frei0r
GSM=yes|no (default: no), requires gsm
JP2=yes|no (default: no), requires openjpeg
LAME=yes|no (default: yes), requires lame
OPENCV=yes|no (default: no), requires opencv
OPENCORE=yes|no (default: no), requires opencore-amr
RTMP=yes|no (default: no), requires rtmpdump
SCHROEDINGER=yes|no (default: no), requires schroedinger
SPEEX=yes|no (default: no), requires speex
VPX=yes|no (default: no), requires libvpx
X264=yes|no (default: yes), requires x264
XVID=yes|no (default: no), requires xvidcore

So I need to install opencv before I can install ffmpeg with the OPENCV=YES variable. But I need to first install a newer ffmpeg without opencv so that I can subsequently install opencv. It seems like a catch-22.

Z038 12-23-2012 12:05 AM

I built ffmpeg from the slackbuild with OPENCV=NO, and that worked. Then I built OpenCV from the slackbuild, and it worked too. Then I tried building ffmpeg again, this time with the OPENCV=yes variable passed to the slackbuild script, and it failed.

This is from config.log:

Code:

gcc -D_ISOC99_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -D_POSIX_C_SOURCE=200112 -D_XOPEN_SOURCE=600 -O2
-march=i486 -mtune=i686 -I/usr/include/openjpeg-1.4 -std=c99 -fomit-frame-pointer -pthread -I/usr/include/dirac
-I/usr/include/opencv /usr/lib/libopencv_calib3d.so /usr/lib/libopencv_contrib.so /usr/lib/libopencv_core.so
/usr/lib/libopencv_features2d.so /usr/lib/libopencv_flann.so /usr/lib/libopencv_gpu.so /usr/lib/libopencv_highgui.so
/usr/lib/libopencv_imgproc.so /usr/lib/libopencv_legacy.so /usr/lib/libopencv_ml.so /usr/lib/libopencv_nonfree.so
/usr/lib/libopencv_objdetect.so /usr/lib/libopencv_photo.so /usr/lib/libopencv_stitching.so /usr/lib/libopencv_ts.so
/usr/lib/libopencv_video.so /usr/lib/libopencv_videostab.so -c -o /tmp/ffconf.XXPh9SQF.o /tmp/ffconf.XXT2JxbG.c
gcc: /usr/lib/libopencv_calib3d.so: linker input file unused because linking not done
gcc: /usr/lib/libopencv_contrib.so: linker input file unused because linking not done
gcc: /usr/lib/libopencv_core.so: linker input file unused because linking not done
gcc: /usr/lib/libopencv_features2d.so: linker input file unused because linking not done
gcc: /usr/lib/libopencv_flann.so: linker input file unused because linking not done
gcc: /usr/lib/libopencv_gpu.so: linker input file unused because linking not done
gcc: /usr/lib/libopencv_highgui.so: linker input file unused because linking not done
gcc: /usr/lib/libopencv_imgproc.so: linker input file unused because linking not done
gcc: /usr/lib/libopencv_legacy.so: linker input file unused because linking not done
gcc: /usr/lib/libopencv_ml.so: linker input file unused because linking not done
gcc: /usr/lib/libopencv_nonfree.so: linker input file unused because linking not done
gcc: /usr/lib/libopencv_objdetect.so: linker input file unused because linking not done
gcc: /usr/lib/libopencv_photo.so: linker input file unused because linking not done
gcc: /usr/lib/libopencv_stitching.so: linker input file unused because linking not done
gcc: /usr/lib/libopencv_ts.so: linker input file unused because linking not done
gcc: /usr/lib/libopencv_video.so: linker input file unused because linking not done
gcc: /usr/lib/libopencv_videostab.so: linker input file unused because linking not done
gcc -Wl,--as-needed -I/usr/include/opencv /usr/lib/libopencv_calib3d.so /usr/lib/libopencv_contrib.so
/usr/lib/libopencv_core.so /usr/lib/libopencv_features2d.so /usr/lib/libopencv_flann.so /usr/lib/libopencv_gpu.so
/usr/lib/libopencv_highgui.so /usr/lib/libopencv_imgproc.so /usr/lib/libopencv_legacy.so /usr/lib/libopencv_ml.so
/usr/lib/libopencv_nonfree.so /usr/lib/libopencv_objdetect.so /usr/lib/libopencv_photo.so /usr/lib/libopencv_stitching.so
/usr/lib/libopencv_ts.so /usr/lib/libopencv_video.so /usr/lib/libopencv_videostab.so -o /tmp/ffconf.XX7WUBhG
/tmp/ffconf.XXPh9SQF.o -lopencore-amrwb -lopencore-amrnb -lmp3lame -lfaac -ldirac_encoder -ldirac_decoder -lm -lstdc++
-ldc1394 -lcelt0 -lm -pthread -lbz2 -lz
/tmp/ffconf.XXPh9SQF.o: In function `check_cvCreateImageHeader':
ffconf.XXT2JxbG.c:(.text+0x1): undefined reference to `cvCreateImageHeader'
collect2: ld returned 1 exit status
ERROR: opencv not found

The OpenCV package is installed. What is the meaning of the "linker input file unused because linking not done" messages?

Z038 12-23-2012 12:41 AM

Ok, I found that the "linker input file unused because linking not done" message is because of the -c flag on the gcc command. And I don't think that's necessarily a problem.

The undefined reference to cvCreateImageHeader may be more of an issue. Why the "ERROR: opencv not found"? It's definitely installed.

Z038 12-23-2012 11:46 AM

Apparently the problem has to do with the way the linker parms are generated with the "-Wl,--as-needed" flag.

I found a thread on the ffmpeg listserv where someone else had this problem. It starts here https://lists.ffmpeg.org/pipermail/f...ne/007527.html, and a later post points here http://thread.gmane.org/gmane.comp.v...45/focus=39448 and here http://code.opencv.org/issues/2110 and finally here in this thread that talks about ToolChain DSOlinking http://wiki.debian.org/ToolChain/DSOLinking.

I gather from the discussions that I need to add a "--no-as-needed" flag somewhere in the ffmpeg configure file to get around this problem, but the discussion is all over my head.

I see this in the ffmpeg configure file that I think is what causes the generation of the commands that fail:

Code:

enabled libopencv  && require_pkg_config opencv opencv/cxcore.h cvCreateImageHeader
I also see this in the configure script, but I'm not sure what it does or what its scope is:

Code:

check_ldflags -Wl,--as-needed
Any ideas where I would add the -Wl,--no-as-needed flag for the link of opencv?

irgunII 12-23-2012 01:06 PM

If it's any consolation, opencv doesn't get found in the ffmpeg for 14.0 either. I used all osrts of others' ffmpeg builds including the one on slackbuilds, and even used the 1.0.x ffmpeg, but *that* one said it couldn't find jpeg (or something like that). I was really hoping to have the opencv as in an app or two I've been following a few users have said it's really helping in lowering mpeg file sizes and such or something to that effect.

Z038 12-23-2012 01:12 PM

I am glad to hear that I'm not the only one having a problem. But a greater consolation would be to find that someone had figured out how to get around it! :-)

I wonder if the ffmpeg slackbuild author or anyone else attempting to use the slackbuild tried building it with opencv, and if so, whether or not they encountered the problem and/or resolved it.

willysr 12-23-2012 05:41 PM

Have you tried using AlienBob's ffmpeg package?

Z038 12-23-2012 05:52 PM

The list of packages included in Alien Bob's build is most of what I want, but it doesn't appear to include opencv. Here is the list: http://www.slackware.com/~alien/slac.../ffmpeg/build/

I can build ffmpeg without a problem from the slackware.org slackbuild so long as I leave out opencv.

willysr 12-23-2012 06:05 PM

I used AlienBob's ffmpeg package and then i compile OpenCV from slackbuilds and it worked

Z038 12-23-2012 09:32 PM

I am able to compile OpenCV from the slackbuild after building ffmpeg from slackbuilds.org also. The failure occurs when trying to rebuild ffmpeg with OPENCV=yes flag.

TommyC7 12-23-2012 10:18 PM

According to the .SlackBuild script, it says OpenCV is broken. Perhaps try a newer version of OpenCV and ffmpeg than the ones on SlackBuilds.org?

walecha 12-23-2012 11:07 PM

Well, this not a fix, just workaround. I always build OpenCV without ffmpeg. So if I already have ffmpeg, I uninstalled it first, build opencv and then reinstall ffmpeg. I think it runs fine without ffmpeg.

Z038 12-24-2012 10:56 AM

I'm marking this solved. I was able to build (via scripts from slackbuilds.org) both 2.4.0 and 2.4.3 (latest stable release) after I installed ffmpeg 0.8.7.

I still have the problem of enabling OpenCV support in ffmpeg, but that was not the focus of this topic. I'll open a new thread if I can't figure it out.


All times are GMT -5. The time now is 11:27 AM.