I have downloaded and installed the ffmpeg library. I want to use it for reading the separate frames of different videos and manipulate them. For that I tried to follow some tutorial from here: http://dranger.com/ffmpeg/tutorial01.html
But I can’t compile my cpp file since I get the following compilation:
Undefined symbols for architecture x86_64:
"av_register_all()", referenced from:
_main in cc9zyUBe.o
_main in ccRz35d4.o
ld: symbol(s) not found for architecture x86_64
collect2: ld returned 1 exit status
When I was installing ffmpeg library, I used arch=x86_64 option in ./configure step.
I use OS X Mountain Lion 10.8.2 and gcc 4.2 compiler.
Does somebody have any clue what can be the reason of this error?
Thanks in advance.
UPDATE:
I’ve already tried many different install options, with static libraries, shared libraries, with/without –arch=x86_64 option. Also installed it with homebrew, result remains the same. Library isn’t recognized. But ffmpeg binary works pretty well, when I use it as a command-line tool.
Finally I have managed to compile my program which uses ffmpeg library.
For some reason I still couldn’t compile it using gcc compiler, but I could do it with g++ compiler.
When the static libraries are installed, all the dependencies must be specified explicitly, and the order of linking of these libraries is also important. So here is the compilation code which finally compiled my program:
pkg-confighere is a utility which prints all the flags and libraries that are needed to properly link the specifiedlibavformatlibrary.Also it’s worth of mentioning, that the source file was renamed from readVideo.C to readVideo.cc, and that
#includestatements have been encompassed usingextern "C"as follows:It is needed because ffmpeg is a C project and program will not compile with C++ compiler if you don’t explicitly state that it is C library.
And if you don’t want to bother with
pkg-configto include all dependencies for ffmpeg libraries, you can install ffmpeg with shared libraries instead of static ones. Then it will compile by simpler call:To install shared libraries, you need to add these 2 options to
./configureprogram when installing ffmpeg:Hope it helps somebody some time …