[Solved] Linker problem while building an example with gcc

Questions that occur when trying to compile FFmpeg.
Post Reply
Tiwenty
Posts: 2
Joined: Thu Jun 29, 2017 10:09 pm

[Solved] Linker problem while building an example with gcc

Post by Tiwenty » Thu Jun 29, 2017 10:35 pm

Hello everyone,

I'm trying to learn how to use the FFmpeg library on Windows but I can't get it to work. I downloaded the 3.3.2 dev build in 64-bit. Now when I try to build an example (metadata.c in this case) with gcc in MinGW, I get a linker error. I'm not really at ease with shared libraries and how they work, but after a few days searching on the web, I came here to ask you.

My config is Win10 64-bit with MinGW and here is the command I am using:

Code: Select all

gcc -o metadata.exe .\metadata.c -I..\..\include\ -L..\..\lib\ -lavformat -lavutil
And I get these errors:

Code: Select all

C:\Users\ME\AppData\Local\Temp\ccP2ryQK.o:metadata.c:(.text+0x44): undefined reference to `av_register_all'
C:\Users\ME\AppData\Local\Temp\ccP2ryQK.o:metadata.c:(.text+0x6c): undefined reference to `avformat_open_input'
C:\Users\ME\AppData\Local\Temp\ccP2ryQK.o:metadata.c:(.text+0xc8): undefined reference to `av_dict_get'
C:\Users\ME\AppData\Local\Temp\ccP2ryQK.o:metadata.c:(.text+0xdf): undefined reference to `avformat_close_input'
It looks like the type of errors I get when I don't link the libraries in the gcc command. But I tried adding all of them like libavcodec, etc. but it doesn't change anything.
I'm pretty sure of the paths I'm using in the command, I get "files not found" errors for the headers of libraries when I purposely misspell them.

So what am I doing wrong?

Thanks in advance for helping me.
Last edited by Tiwenty on Fri Jun 30, 2017 5:43 pm, edited 1 time in total.

Tiwenty
Posts: 2
Joined: Thu Jun 29, 2017 10:09 pm

Re: Linker problem while building an example with gcc

Post by Tiwenty » Fri Jun 30, 2017 5:41 pm

Okay so I found what was the problem. As I'm using MinGW, it includes a 32-bits compiler. But I didn't think of it, and downloaded the 64-bits FFmpeg builds on the website. So I tried downloading the 32-bits builds and it built and linked successfully with only -lavformat and -lavutil parameters. And to run the program I needed the DLL which can be found in the Shared build (and 32-bits of course). Thanks!

Post Reply
'