[Libav-user] Linking ffmpeg libraries on Windows
Alex Cohn
alexcohn at netvision.net.il
Thu Apr 5 13:10:46 CEST 2012
On Thu, Apr 5, 2012 at 03:14, Gustav González <xtingray at gmail.com> wrote:
> 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?
>
> Thanks!
>
> --
> ============================
> Gustav Gonzalez
> xtingray at gmail.com
> ============================
Do you use any av_* functions that the linker does not complain about?
I think you have the linking syntax wrong. -L normally points to a
directory, not a file. Also, zeranoe provides the import libraries in
/lib directory. Thus, you probably need something like:
-L C:/QtSDK/Desktop/ffmpeg/lib -lavformat-53.dll -lavutil-51.dll
BR,
Alex Cohn
PS: to understand how Mingw works with dlls and "import libraries",
look at http://www.mingw.org/wiki/CreateImportLibraries.
More information about the Libav-user
mailing list