[Libav-user] ffmpeg static library linking issue

yuvaraj r yuvaraj.tr at gmail.com
Tue Feb 7 12:04:23 CET 2012


Hi

As per my understanding all the symbols in libraries are linked properly.

Now problem with,the way of using static library linking.

Could anybody provide steps to compile ffmpeg based example programs here?

Thanks

Yuvaraj



On Tue, Feb 7, 2012 at 4:21 PM, Alex Cohn <alexcohn at netvision.net.il> wrote:
> On Tue, Feb 7, 2012 at 12:43, yuvaraj r <yuvaraj.tr at gmail.com> wrote:
>> I have only static libraries
>>
>> Thanks
>>
>> Yuvaraj
>
> I'd recommend to add -Wl,--no-undefined to your gcc command line.
>
> Alex
>
>> On Tue, Feb 7, 2012 at 4:10 PM, Alex Cohn <alexcohn at netvision.net.il> wrote:
>>> On Tue, Feb 7, 2012 at 06:54, yuvaraj r <yuvaraj.tr at gmail.com> wrote:
>>>> Hi All,
>>>>
>>>>
>>>> I compiled the ffmpeg source to generate the static(.a foramt)
>>>> libraries  in linux.
>>>>
>>>> When i am linking the static libraries with my application,
>>>>
>>>> i am getting undefined reference for many functions.
>>>>
>>>> Even i tried with pkg-config.
>>>>
>>>> Here command , what i tried
>>>>
>>>>
>>>> gcc -shared -Wl,-soname,librecorder.so.1 '-Wl,-rpath,lib'  -lpthread
>>>> -lXdamage -lXfixes -lXmu -lXi -lX11
>>>> -L/home/peter/Desktop/screenrecorder/librecorder/src/../dependencies/lib
>>>>  -lavformat -lavcodec -lavutil -lswscale `pkg-config --libs --cflags
>>>> libavutil` `pkg-config --libs --cflags libswscale` `pkg-config --libs
>>>> --cflags libavcodec` `pkg-config --libs --cflags libavformat` -o
>>>> librecorder.so.1.1 init.o main_entry.o xtoffmpeg.o
>>>>
>>>>
>>>> It is generated the librecorder library. I have all dependency libs
>>>>
>>>> when executing ld command
>>>>
>>>> #ld librecorder.so.1.1
>>>>
>>>> librecorder.so.1: undefined reference to `av_new_stream'
>>>> librecorder.so.1: undefined reference to `av_read_packet'
>>>> librecorder.so.1: undefined reference to `avcodec_alloc_frame'
>>>> librecorder.so.1: undefined reference to `av_close_input_file'
>>>> librecorder.so.1: undefined reference to `audio_resample'
>>>> librecorder.so.1: undefined reference to `avcodec_find_encoder'
>>>> librecorder.so.1: undefined reference to `av_find_input_format'
>>>> librecorder.so.1: undefined reference to `avcodec_encode_audio'
>>>> librecorder.so.1: undefined reference to `dump_format'
>>>> librecorder.so.1: undefined reference to `av_open_input_file'
>>>> librecorder.so.1: undefined reference to `avcodec_find_decoder'
>>>> librecorder.so.1: undefined reference to `avcodec_close'
>>>> librecorder.so.1: undefined reference to `av_find_stream_info'
>>>> librecorder.so.1: undefined reference to `audio_resample_init'
>>>> librecorder.so.1: undefined reference to `avpicture_get_size'
>>>> librecorder.so.1: undefined reference to `av_register_all'
>>>> librecorder.so.1: undefined reference to `avcodec_decode_audio'
>>>> librecorder.so.1: undefined reference to `avcodec_open'
>>>> librecorder.so.1: undefined reference to `avcodec_encode_video'
>>>> librecorder.so.1: undefined reference to `av_destruct_packet_nofree'
>>>> librecorder.so.1: undefined reference to `avpicture_fill'
>>>> librecorder.so.1: undefined reference to `av_set_parameters'
>>>> librecorder.so.1: undefined reference to `av_alloc_format_c
>>>>
>>>> Now problem with static libraries.
>>>>
>>>>
>>>> #pkg-config --list-all | grep mpeg
>>>> libswscale                       libswscale - FFmpeg image rescaling library
>>>> libavutil                        libavutil - FFmpeg utility library
>>>> libavformat                      libavformat - FFmpeg container format library
>>>> libavcodec                       libavcodec - FFmpeg codec library
>>>>
>>>>
>>>> How do i solve this issue
>>>>
>>>>
>>>> Thanks
>>>>
>>>>
>>>> Yuvaraj R
>>>
>>> As far as I know, -l flag on the gcc command line will prefer the
>>> shared version of the library. I.e. if you have both libavformat.a and
>>> libavformat.so visible to gcc, the latter will be used.
>>>
>>> BR,
>>> Alex
> _______________________________________________
> Libav-user mailing list
> Libav-user at ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/libav-user


More information about the Libav-user mailing list