[Libav-user] Linking ffmpeg libraries on Windows

Matthew Einhorn moiein2000 at gmail.com
Thu Apr 5 02:37:16 CEST 2012


2012/4/4 Gustav González <xtingray at gmail.com>:
> Hi,
>
> Currently I'm trying to compile my C++ project on Windows 7.
> I want to know if there are any kind of considerations about how to link the
> ffmpeg libraries from a C/C++ program on MS platforms.
>
> I downloaded these files:
> http://ffmpeg.zeranoe.com/builds/win32/dev/ffmpeg-0.8-win32-dev.7z
> http://ffmpeg.zeranoe.com/builds/win32/shared/ffmpeg-0.8-win32-shared.7z
>
> For the compilation process I'm using this option and it seems to work:
> -I"c:\QtSDK\Desktop\ffmpeg\include"
>
> My linking option is this:
>
>  -LC:/QtSDK/Desktop/ffmpeg/bin/avcodec-53.dll
> -LC:/QtSDK/Desktop/ffmpeg/bin/avformat-53.dll
> -LC:/QtSDK/Desktop/ffmpeg/bin/avutil-51.dll
>
> But the linking process fails printing a lot of these messages:
>
> ./release\kffmpegmoviegenerator.o:kffmpegmoviegenerator.cpp:(.text+0x390):
> undefined reference to `avcodec_close'
> ./release\kffmpegmoviegenerator.o:kffmpegmoviegenerator.cpp:(.text+0x39c):
> undefined reference to `av_free'
> ./release\kffmpegmoviegenerator.o:kffmpegmoviegenerator.cpp:(.text+0x3a6):
> undefined reference to `av_free'
> ./release\kffmpegmoviegenerator.o:kffmpegmoviegenerator.cpp:(.text+0x3b7):
> undefined reference to `av_free'
> ./release\kffmpegmoviegenerator.o:kffmpegmoviegenerator.cpp:(.text+0x3c2):
> undefined reference to `av_free'
> ./release\kffmpegmoviegenerator.o:kffmpegmoviegenerator.cpp:(.text+0x408):
> undefined reference to `av_write_trailer'
>
> Any hint? Any suggestion?
>

Dunno if you're using VC++, but to use the exported dll functions in a
c++ project you have to place the includes (e.g. avformat.h) in extern
"C" braces. Otherwise the names get mangled up.

Matt


More information about the Libav-user mailing list