[Libav-user] Linking with libav*

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

[Libav-user] Linking with libav*

Simon Brown
I have a modified version of the demuxing_decoding.c program (with ffmpeg from the latest git head), that I copied into a C++ file (to link it with other software that requires C++).  The program compiles, but when linking it fails to find the libraries, so produces undefined references to all the av calls that I make.

My compile and link script is:
gcc -o demux_decode demux_decode.cpp -L/usr/local/lib -lavformat .... 
(sorry, my VM has crashed and I can't copy/paste at the moment)

Is there any issue linking C libraries with C++?  Is there anything else I should be doing?  I had assumed it was a "shared-object" problem, and rebuilt everything with --enable-shared set, but that hasn't solved it.

Any advice greatly appreciated,

Simon

_______________________________________________
Libav-user mailing list
[hidden email]
https://ffmpeg.org/mailman/listinfo/libav-user

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".
Reply | Threaded
Open this post in threaded view
|

Re: Linking with libav*

Carl Eugen Hoyos-2
Am Di., 13. Aug. 2019 um 14:11 Uhr schrieb Simon Brown
<[hidden email]>:

> I have a modified version of the demuxing_decoding.c program (with ffmpeg from
> the latest git head), that I copied into a C++ file (to link it with other software that
> requires C++).  The program compiles, but when linking it fails to find the libraries,
> so produces undefined references to all the av calls that I make.

Which undefined references?

> My compile and link script is:
> gcc -o demux_decode demux_decode.cpp -L/usr/local/lib -lavformat ....

"..." is the important part here as libavformat is not self-contained.
libavutil is a requirement for all other FFmpeg libraries, libavcodec
is also needed for libavformat.

Carl Eugen
_______________________________________________
Libav-user mailing list
[hidden email]
https://ffmpeg.org/mailman/listinfo/libav-user

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".
Reply | Threaded
Open this post in threaded view
|

Re: Linking with libav*

Gonzalo Garramuño
In reply to this post by Simon Brown

El 13/8/19 a las 09:11, Simon Brown escribió:
>
>
> Is there any issue linking C libraries with C++?  Is there anything
> else I should be doing?  I had assumed it was a "shared-object"
> problem, and rebuilt everything with --enable-shared set, but that
> hasn't solved it.
>
Make sure you include the libav.... .h files with an extern "C" guard, like:

extern "C" {

#include "libavutil/avutil.h"
#include "libavformat/avformat.h"

}

That should make all symbols visible without mangling them.

--
Gonzalo Garramuño

_______________________________________________
Libav-user mailing list
[hidden email]
https://ffmpeg.org/mailman/listinfo/libav-user

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".
Reply | Threaded
Open this post in threaded view
|

Re: Linking with libav*

Simon Brown
In reply to this post by Carl Eugen Hoyos-2


On Tue, 13 Aug 2019 at 13:25, Carl Eugen Hoyos <[hidden email]> wrote:
"..." is the important part here as libavformat is not self-contained.
libavutil is a requirement for all other FFmpeg libraries, libavcodec
is also needed for libavformat.

Carl Eugen

Thank you Carl, yes - I am aware I needed other libraries, and had included them, in full I've got:
lavformat, lavcodec, lavdevice, lavfilter, lavutil 

However, more thanks go to Gonzalo, who hit the nail on the head.  I had put 'extern "C"' around my header files, but then must have removed it in a bid to try other options when I was still trying to link without the .so libraries.  Now that extern "C" is back in place they link fine.

All solved now, thanks,

Simon

_______________________________________________
Libav-user mailing list
[hidden email]
https://ffmpeg.org/mailman/listinfo/libav-user

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".