Discussion:
[libav-user] -lavcodec on os X
Jasper Leemans
2008-04-14 10:16:19 UTC
Permalink
hi everyone,

I wrote a Qt/ffmpeg program which compiles fine with the -lavcodec flag on my Linux box.

then I installed ffmpeg on my os X machine with general ./configure make sudo make install
(no need for the audio codecs I only use video)

During linking however I get undefined reference errors but I know the library is found (otherwise
he would complain on my -lavcodec flag, and the libav* libraries are present in /usr/local/lib/)

The errors look like this, are there any flags I should parse to configure?
Or is something else wrong?

Undefined symbols:
"avcodec_find_encoder(CodecID)", referenced from:
RecordDialog::setupRecording(int, int, bool, float)in recordmovie.o
"avcodec_register_all()", referenced from:
RecordDialog::RecordDialog(QWidget*)in recordmovie.o
"av_free(void*)", referenced from:
RecordDialog::closeRecording() in recordmovie.o
RecordDialog::closeRecording() in recordmovie.o
"avcodec_close(AVCodecContext*)", referenced from:
RecordDialog::closeRecording() in recordmovie.o
"avcodec_encode_video(AVCodecContext*, unsigned char*, int, AVFrame const*)", referenced from:
RecordDialog::writeFrame(unsigned char*)in recordmovie.o
RecordDialog::closeRecording() in recordmovie.o
"avcodec_init()", referenced from:
RecordDialog::RecordDialog(QWidget*)in recordmovie.o
"avcodec_alloc_context()", referenced from:
RecordDialog::setupRecording(int, int, bool, float)in recordmovie.o
"avcodec_alloc_frame()", referenced from:
RecordDialog::setupRecording(int, int, bool, float)in recordmovie.o
"avcodec_open(AVCodecContext*, AVCodec*)", referenced from:
RecordDialog::setupRecording(int, int, bool, float)in recordmovie.o
ld: symbol(s) not found
collect2: ld returned 1 exit status
make: *** [debug/open1394.app/Contents/MacOS/open1394] Error 1

These are the same typical you get when you forget the -lavcodec flag, but I didn't so i'm confused...

wkr,

jasper
_________________________________________________________________
Connect to the next generation of MSN Messenger?
http://imagine-msn.com/messenger/launch80/default.aspx?locale=en-us&source=wlmailtagline
Luca Abeni
2008-04-14 10:28:11 UTC
Permalink
Hi Jasper,
Post by Jasper Leemans
hi everyone,
I wrote a Qt/ffmpeg program which compiles fine with the -lavcodec flag on my Linux box.
then I installed ffmpeg on my os X machine with general ./configure make sudo make install
(no need for the audio codecs I only use video)
[...]
Post by Jasper Leemans
RecordDialog::setupRecording(int, int, bool, float)in recordmovie.o
ld: symbol(s) not found
collect2: ld returned 1 exit status
make: *** [debug/open1394.app/Contents/MacOS/open1394] Error 1
These are the same typical you get when you forget the -lavcodec flag
On some systems, I've seen similar errors when the "-lavcodec" option
is placed in the wrong position in the compilation command.
Since you did not post the command you used for compiling/linking your
program, it's hard to tell where the problem is.

Anyway:
1) Do the "ffmpeg", "ffplay", and "ffserver" executable compile and link
correctly in your OS X installation? If yes, you can look at the command
lines used by the ffmpeg build system to compile and link them...
2) In general, you can use the "pkg-config" command to know the correct
options (in the correct order).


Luca
Jasper Leemans
2008-04-14 11:07:55 UTC
Permalink
Sorry, the linking command that errors is this one:

c++ -headerpad_max_install_names -o debug/open1394.app/Contents/MacOS/open1394 open1394.o mainwindow.o monitor.o select.o myconv.o mytrans.o captureset.o featureset.o multigrab.o reticles.o reticlesdialog.o options.o recordmovie.o moc_mainwindow.o moc_monitor.o moc_select.o moc_captureset.o moc_featureset.o moc_multigrab.o moc_reticlesdialog.o moc_options.o moc_recordmovie.o qrc_open1394.o -F/usr/local/Trolltech/Qt-4.3.2/lib -L/usr/local/Trolltech/Qt-4.3.2/lib -ldc1394 -lavcodec -framework QtOpenGL -L/usr/local/Trolltech/Qt-4.3.2/lib -F/usr/local/Trolltech/Qt-4.3.2/lib -framework QtGui -framework Carbon -framework AppKit -framework QtCore -lz -lm -framework ApplicationServices -framework OpenGL -framework AGL


I manually tried running the command again whilst playing with the position of -lavcodec, no results though.
I also tried explicitly adding -L/usr/local/lib but this also didn't help, and shouldn't even be necessary.

----------------------------------------
Date: Mon, 14 Apr 2008 12:28:11 +0200
From: lucabe72 at email.it
To: libav-user at mplayerhq.hu
Subject: Re: [libav-user] -lavcodec on os X
Hi Jasper,
Post by Jasper Leemans
hi everyone,
I wrote a Qt/ffmpeg program which compiles fine with the -lavcodec flag on my Linux box.
then I installed ffmpeg on my os X machine with general ./configure make sudo make install
(no need for the audio codecs I only use video)
[...]
Post by Jasper Leemans
RecordDialog::setupRecording(int, int, bool, float)in recordmovie.o
ld: symbol(s) not found
collect2: ld returned 1 exit status
make: *** [debug/open1394.app/Contents/MacOS/open1394] Error 1
These are the same typical you get when you forget the -lavcodec flag
On some systems, I've seen similar errors when the "-lavcodec" option
is placed in the wrong position in the compilation command.
Since you did not post the command you used for compiling/linking your
program, it's hard to tell where the problem is.
1) Do the "ffmpeg", "ffplay", and "ffserver" executable compile and link
correctly in your OS X installation? If yes, you can look at the command
lines used by the ffmpeg build system to compile and link them...
2) In general, you can use the "pkg-config" command to know the correct
options (in the correct order).
Luca
_______________________________________________
libav-user mailing list
libav-user at mplayerhq.hu
https://lists.mplayerhq.hu/mailman/listinfo/libav-user
_________________________________________________________________
Discover the new Windows Vista
http://search.msn.com/results.aspx?q=windows+vista&mkt=en-US&form=QBRE
Luca Abeni
2008-04-14 11:15:02 UTC
Permalink
Post by Jasper Leemans
c++ -headerpad_max_install_names -o debug/open1394.app/Contents/MacOS/open1394 open1394.o mainwindow.o monitor.o select.o myconv.o mytrans.o captureset.o featureset.o multigrab.o reticles.o reticlesdialog.o options.o recordmovie.o moc_mainwindow.o moc_monitor.o moc_select.o moc_captureset.o moc_featureset.o moc_multigrab.o moc_reticlesdialog.o moc_options.o moc_recordmovie.o qrc_open1394.o -F/usr/local/Trolltech/Qt-4.3.2/lib -L/usr/local/Trolltech/Qt-4.3.2/lib -ldc1394 -lavcodec -framework QtOpenGL -L/usr/local/Trolltech/Qt-4.3.2/lib -F/usr/local/Trolltech/Qt-4.3.2/lib -framework QtGui -framework Carbon -framework AppKit -framework QtCore -lz -lm -framework ApplicationServices -framework OpenGL -framework AGL
Uhmmm... Since you are compiling a C++ program, did you remember about
the "extern C" stuff? Missing it can cause linking errors similar to the ones
you are seeing...

Also, you are linking libavcodec, but you do not seem to be linking libavutil.

Luca
Jasper Leemans
2008-04-14 11:24:51 UTC
Permalink
This is true, however I already tried adding -lavutil before (and the other ffmpeg libraries for that matter),
does not make a difference. I compile my project fine with only the -lavcodec flag on my linux box, and that works flawlessly,
I don't see why this would be different on os X.

I also tried installing different (older) ffmpeg releases and build them with flags like --enable-shared etc., still nothing...> Date: Mon, 14 Apr 2008 13:15:02 +0200> From: lucabe72 at email.it> To: libav-user at mplayerhq.hu> Subject: Re: [libav-user] -lavcodec on os X> > Jasper Leemans wrote:> > Sorry, the linking command that errors is this one:> > > > c++ -headerpad_max_install_names -o debug/open1394.app/Contents/MacOS/open1394 open1394.o mainwindow.o monitor.o select.o myconv.o mytrans.o captureset.o featureset.o multigrab.o reticles.o reticlesdialog.o options.o recordmovie.o moc_mainwindow.o moc_monitor.o moc_select.o moc_captureset.o moc_featureset.o moc_multigrab.o moc_reticlesdialog.o moc_options.o moc_recordmovie.o qrc_open1394.o -F/usr/local/Trolltech/Qt-4.3.2/lib -L/usr/local/Trolltech/Qt-4.3.2/lib -ldc1394 -lavcodec -framework QtOpenGL -L/usr/local/Trolltech/Qt-4.3.2/lib -F/usr/local/Trolltech/Qt-4.3.2/lib -framework QtGui -framework Carbon -framework AppKit -framework QtCore -lz -lm -framework ApplicationServices -framework OpenGL -framework AGL> Uhmmm... Since you are compiling a C++ program, did you remember about> the "extern C" stuff? Missing it can cause linking errors similar to the ones> you are seeing...> > Also, you are linking libavcodec, but you do not seem to be linking libavutil.> > Luca> _______________________________________________> libav-user mailing list> libav-user at mplayerhq.hu> https://lists.mplayerhq.hu/mailman/listinfo/libav-user
_________________________________________________________________
Invite your mail contacts to join your friends list with Windows Live Spaces. It's easy!
http://spaces.live.com/spacesapi.aspx?wx_action=create&wx_url=/friends.aspx&mkt=en-us
Jasper Leemans
2008-04-14 12:19:05 UTC
Permalink
Yes I fixed in thanks guys,

first of all, I did forget about the extern C stuff,
although in Linux I had no problems including the avcodec.h file the normal way,
the proper way is:

extern "C" {
#include "libavcodec/avcodec.h"
}

This got rid of almost all errors except undefined reference to av_free(),
I fixed this by including -lavutil.

why my code compiles on linux without -lavutil still remains a mistery (version related?).

----------------------------------------
Post by Jasper Leemans
Date: Mon, 14 Apr 2008 13:15:02 +0200
From: lucabe72 at email.it
To: libav-user at mplayerhq.hu
Subject: Re: [libav-user] -lavcodec on os X
Post by Jasper Leemans
c++ -headerpad_max_install_names -o debug/open1394.app/Contents/MacOS/open1394 open1394.o mainwindow.o monitor.o select.o myconv.o mytrans.o captureset.o featureset.o multigrab.o reticles.o reticlesdialog.o options.o recordmovie.o moc_mainwindow.o moc_monitor.o moc_select.o moc_captureset.o moc_featureset.o moc_multigrab.o moc_reticlesdialog.o moc_options.o moc_recordmovie.o qrc_open1394.o -F/usr/local/Trolltech/Qt-4.3.2/lib -L/usr/local/Trolltech/Qt-4.3.2/lib -ldc1394 -lavcodec -framework QtOpenGL -L/usr/local/Trolltech/Qt-4.3.2/lib -F/usr/local/Trolltech/Qt-4.3.2/lib -framework QtGui -framework Carbon -framework AppKit -framework QtCore -lz -lm -framework ApplicationServices -framework OpenGL -framework AGL
Uhmmm... Since you are compiling a C++ program, did you remember about
the "extern C" stuff? Missing it can cause linking errors similar to the ones
you are seeing...
Also, you are linking libavcodec, but you do not seem to be linking libavutil.
Luca
_______________________________________________
libav-user mailing list
libav-user at mplayerhq.hu
https://lists.mplayerhq.hu/mailman/listinfo/libav-user
_________________________________________________________________
News, entertainment and everything you care about at Live.com. Get it now!
http://www.live.com/getstarted.aspx
Luca Abeni
2008-04-14 12:26:33 UTC
Permalink
Post by Jasper Leemans
first of all, I did forget about the extern C stuff,
although in Linux I had no problems including the avcodec.h file the normal way,
extern "C" {
#include "libavcodec/avcodec.h"
}
This got rid of almost all errors except undefined reference to av_free(),
I fixed this by including -lavutil.
why my code compiles on linux without -lavutil still remains a mistery (version related?).
If I remember well, the ELF format used by Linux tools allow to link
.so files with other .so files. So, libavcodec.so is linked with
libavutil.so during ffmpeg build, and you do not need to explicitly
link libavutil.so.

Maybe OS X tools do not allow similar tricks, or you are linking static
libraries on OS X?


Luca
Mark Heath
2008-04-14 10:55:44 UTC
Permalink
Post by Jasper Leemans
hi everyone,
I wrote a Qt/ffmpeg program which compiles fine with the -lavcodec flag on my Linux box.
then I installed ffmpeg on my os X machine with general ./configure make sudo make install
(no need for the audio codecs I only use video)
During linking however I get undefined reference errors but I know
the library is found (otherwise
he would complain on my -lavcodec flag, and the libav* libraries are
present in /usr/local/lib/)
The errors look like this, are there any flags I should parse to configure?
Did you use the --enable-shared on the configure command line?

if you look in /usr/local/lib are the .dynlib files there (not just
the .a) ?

I do have a working installation of ffmpeg shared libraries on OSX (ppc)

Mark
Jasper Leemans
2008-04-14 11:45:21 UTC
Permalink
yes I compiled and installed using different flags,
I just did a clean install with the flags --enable-shared and --disable-mmx to be sure,
but still the problem persist.
The .dylib files are there.

What compiler options do you use for your lavcodec apps on os X?> From: mjpeg0 at silicontrip.org> To: libav-user at mplayerhq.hu> Date: Mon, 14 Apr 2008 20:55:44 +1000> Subject: Re: [libav-user] -lavcodec on os X> > > On 14/04/2008, at 8:16 PM, Jasper Leemans wrote:> > >> > hi everyone,> >> > I wrote a Qt/ffmpeg program which compiles fine with the -lavcodec > > flag on my Linux box.> >> > then I installed ffmpeg on my os X machine with general ./configure > > make sudo make install> > (no need for the audio codecs I only use video)> >> > During linking however I get undefined reference errors but I know > > the library is found (otherwise> > he would complain on my -lavcodec flag, and the libav* libraries are > > present in /usr/local/lib/)> >> > The errors look like this, are there any flags I should parse to > > configure?> > Did you use the --enable-shared on the configure command line?> > if you look in /usr/local/lib are the .dynlib files there (not just > the .a) ?> > I do have a working installation of ffmpeg shared libraries on OSX (ppc)> > Mark> _______________________________________________> libav-user mailing list> libav-user at mplayerhq.hu> https://lists.mplayerhq.hu/mailman/listinfo/libav-user
_________________________________________________________________
News, entertainment and everything you care about at Live.com. Get it now!
http://www.live.com/getstarted.aspx
Mark Heath
2008-04-14 23:37:11 UTC
Permalink
Post by Jasper Leemans
yes I compiled and installed using different flags,
I just did a clean install with the flags --enable-shared and --
disable-mmx to be sure,
but still the problem persist.
The .dylib files are there.
What compiler options do you use for your lavcodec apps on os X?
gcc -O3 -I/usr/local/include/ffmpeg -I/usr/local/include/mjpegtools -
lavcodec -lavformat -lavutil -lmjpegutils libav2yuv.c -o libav2yuv

Although I'm not using C++

If anyone is interested in some of my yuv stream editing tools, you
can find them here. http://silicontrip.net/~mark/lavtools/

Mark

Loading...