Ask Your Question
0

Error building OpenCV 3.0.0 with FFMPEG

asked 2015-07-27 12:14:11 -0500

ujjwal gravatar image

Hello,

This is my first question on this forum. I have been using OpenCV for a while. However I have recently changed my system to a cluster where I do not have any admin permission. The problem is like this :

In my home folder I installed FFMPEG ( latest stable version available on ffmpeg site). I installed it in $HOME, and so in $HOME/lib there are the library files installed. For more information I compiled FFMPEG with following options :-

./configure --prefix=$HOME --enable-shared --enable-pic

I then downloaded the latest stable version of OpenCV 3.0.0 and configured it using ccmake. When I try to "make -j8", it gives me the following error.

  Scanning dependencies of target opencv_videoio
[ 63%] [ 63%] [ 63%] [ 63%] [ 63%] [ 63%] Building CXX object modules/videoio/CMakeFiles/opencv_videoio.dir/src/cap.cpp.o
Building CXX object modules/videoio/CMakeFiles/opencv_videoio.dir/src/cap_mjpeg_decoder.cpp.o
Building CXX object modules/videoio/CMakeFiles/opencv_videoio.dir/src/cap_images.cpp.o
Building CXX object modules/videoio/CMakeFiles/opencv_videoio.dir/src/cap_v4l.cpp.o
Building CXX object modules/videoio/CMakeFiles/opencv_videoio.dir/src/cap_mjpeg_encoder.cpp.o
Building CXX object modules/videoio/CMakeFiles/opencv_videoio.dir/src/cap_ffmpeg.cpp.o
In file included from /home/uujjwal/libraries/opencv-nogpu/opencv-3.0.0/modules/videoio/src/cap_ffmpeg.cpp:45:0:
/home/uujjwal/libraries/opencv-nogpu/opencv-3.0.0/modules/videoio/src/cap_ffmpeg_impl.hpp:1546:71: error: use of enum 'AVCodecID' without previous declaration
/home/uujjwal/libraries/opencv-nogpu/opencv-3.0.0/modules/videoio/src/cap_ffmpeg_impl.hpp:1556:83: error: use of enum 'AVCodecID' without previous declaration
make[2]: *** [modules/videoio/CMakeFiles/opencv_videoio.dir/src/cap_ffmpeg.cpp.o] Error 1
make[2]: *** Waiting for unfinished jobs....

However without ffmpeg support it works fine. However I need ffmpeg support due to the nature of my work.

In trying to resolve the problem, I tried installing OpenCV 2.4.11 but it also gave this error. The latest GIT version does not give me this error but rather an error a part of which goes like this

inking CXX shared library ../../lib/libopencv_highgui.so /usr/bin/ld: /home/matheus/ffmpeg_build/lib/../lib/libavcodec.a(avpacket.o): relocation R_X86_64_32 against `.rodata.str1.1' can not be used

In trying to resolve the problem I searched and found the following link http://answers.opencv.org/question/12597/build-problems-for-opencv-241-with-ubuntu-1204-lts/

However, one of the answers over there mentioned changing some lines in cap_ffmpeg_impl.hpp file. I tried doing that but either i am not able to do it correctly or something else is going wrong and it is not working. Exact line numbers and exact changes are not mentioned and so I am having difficulty changing things and being sure.

I am using Fedora 19 (Schrodinger Cat) as the operating system I hope the details of my question are clear and I hope that the community would oblige me with a good response.

Regards

Ujjwal

edit retag flag offensive close merge delete

Comments

Have you tried with installing the ffmpeg-devel package ?

sudo yum install ffmpeg-devel
Eduardo gravatar imageEduardo ( 2015-07-28 03:51:49 -0500 )edit

Hello., I did not, because I do not have root permissions on the cluster. However I did compile ffmpeg from source as specified in the question. I installed in #{HOME} and in my ~/.bashrc file I did export ${HOME}/lib as the LD_LIBRARY_PATH. I can see relevant header files in $HOME/include and library files in $HOME/lib

ujjwal gravatar imageujjwal ( 2015-07-28 04:14:48 -0500 )edit

3 answers

Sort by ยป oldest newest most voted
0

answered 2015-08-06 09:05:48 -0500

Ulrich Stern gravatar image

I posted what worked for me on stackoverflow, where I also have a link to my OpenCV issue tracker post.

@answers.opencv, I do not know why you did not allow my previous answer through, and I will stop trying after this attempt. As a general design principle, I strongly dislike repeating code (answers) if I can reuse (link).

edit flag offensive delete link more

Comments

a cheesy link to SO is not considered a valid answer...

berak gravatar imageberak ( 2015-08-07 02:47:25 -0500 )edit

@berak, I have been unhappy with "link answers" as well when the links are poor -- e.g., make me search for the answer on the linked page. But this case is very different. The link is directly to the answer, the answer is exactly to the question, and the answer is written by the same author (I would likely not do a better job here). So for negligible cost to the reader I gain the advantage to only have to update one place if I want to improve the answer (which I did twice), and may not have done updates for three places (I have two links to my answer), so readers benefit, too. So while it is a trade-off, to me the link clearly seemed the better choice than "copy and paste."

Ulrich Stern gravatar imageUlrich Stern ( 2015-08-10 10:16:37 -0500 )edit

@berak, re: not letting my answers through originally (which I assume was you), do you think this benefits OpenCV users with this issue, given that it is a correct answer?

Ulrich Stern gravatar imageUlrich Stern ( 2015-08-10 10:29:14 -0500 )edit

yes, apologies.

still, for the next time, make an answer here ! (who cares about SO ? noone. it might as well not exist.)

berak gravatar imageberak ( 2015-08-10 10:39:22 -0500 )edit
0

answered 2015-09-23 10:25:41 -0500

maythe4thbewithu gravatar image

1) use the opencv source from here

2) --> relocation R_X86_64_32 against `.rodata.str1.1' can not be used

this error comes from some of libraries used by ffpmeg do not compile with --enable-shared

most probably the libvpx, please use "make clean" first before you reset ./configure with --enable-shared

and recompile those libraries.

3) recompile ffmpeg with --enable-shared and others

4) recompile opencv

edit flag offensive delete link more
0

answered 2016-01-14 10:38:54 -0500

sergiomb gravatar image

in Fedora 23 I suspect that is hardened builds :

 /bin/sh ../libtool --tag=CXX --silent --tag=CC   --mode=link gcc  -O2 -g -pipe -Wall -Werror=format-security Y_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -m64 -mtune=generic -Wformat  -Wl,-z,relro -specs=/usr/lib/rpm/redhat/redhat-hardened-ld -o bootstrap bootstrap.o  -lmpeg3 -lopencv_video -lopencv_objdetect -lopencv_legacy  -lm -ldl -lpthread

error:

/usr/bin/ld: bootstrap.o: relocation R_X86_64_32 against '.rodata' can not be used when making a shared object; recompile with -fPIC
bootstrap.o: error adding symbols: Bad value
collect2: error: ld returned 1 exit status

without hardened:

/bin/sh ../libtool --tag=CXX --silent --tag=CC   --mode=link gcc  -O2 -g -pipe -Wall -Werror=for-Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -m64 -mtune=generic -Wformat  -Wl,-z,relro -o bootstrap bootstrap.o  -lmpeg3 -lopencv_video -lopencv_objdetect -lopencv_legacy  -lm -ldl -lpthread

(remove -specs=/usr/lib/rpm/redhat/redhat-hardened-ld is enough)

Succeed

edit flag offensive delete link more
Login/Signup to Answer

Question Tools

1 follower

Stats

Asked: 2015-07-27 12:14:11 -0500

Seen: 8,842 times

Last updated: Jan 14 '16