News:

The new Release 25.03 is out! You can download binaries for Windows and many major Linux distros here .

Main Menu

Compiling the FFMPEG library

Started by DavidNorgren, July 15, 2014, 01:23:47 AM

Previous topic - Next topic

DavidNorgren

Hello, I'm trying to compile some simple code using the FFMPEG library:

extern "C" { // also tried without this
    #include <libavcodec/avcodec.h>
}

int main()
{
    AVCodec* codec;
    avcodec_register_all();
    return 0;
}


The header file contains the AVCodec struct and void avcodec_register_all(void); but I still get undefined reference to `avcodec_register_all'. It doesn't complain about the AVCodec pointer.

My project build options:

Linker Settings->Link Libraries: C:\Libs\ffmpeg\lib\avcodec.lib
Search Directories->Compiler: C:\Libs\ffmpeg\include
Search Directories->Linker: C:\Libs\ffmpeg\lib

Any ideas why I get this error? I've searched the internet for several hours but without luck.

stahta01

C Programmer working to learn more about C++.
On Windows 10 64 bit and Windows 11 64 bit.
--
When in doubt, read the CB WiKi FAQ. [url="http://wiki.codeblocks.org"]http://wiki.codeblocks.org[/url]

DavidNorgren

Quote from: stahta01 on July 15, 2014, 01:29:53 AM
http://wiki.codeblocks.org/index.php?title=FAQ-Compiling_%28errors%29#Q:_How_do_I_troubleshoot_a_compiler_problem.3F

The build log says:


-------------- Clean: Debug in ffmpeg (compiler: GNU GCC Compiler)---------------

Cleaned "ffmpeg - Debug"

-------------- Build: Debug in ffmpeg (compiler: GNU GCC Compiler)---------------

mingw32-g++.exe -Wall -fexceptions -g -std=c++11 -IC:\Libs\ffmpeg\include -IC:\Libs\ffmpeg\include\libavcodec -c C:\Users\David\Downloads\ffmpeg\main.cpp -o obj\Debug\main.o
C:\Users\David\Downloads\ffmpeg\main.cpp: In function 'int main()':
C:\Users\David\Downloads\ffmpeg\main.cpp:9:14: warning: unused variable 'codec' [-Wunused-variable]
mingw32-g++.exe -LC:\Libs\ffmpeg\lib -o bin\Debug\ffmpeg.exe obj\Debug\main.o   C:\Libs\ffmpeg\lib\avcodec.lib
obj\Debug\main.o: In function `main':
C:/Users/David/Downloads/ffmpeg/main.cpp:10: undefined reference to `avcodec_register_all'
collect2.exe: error: ld returned 1 exit status
Process terminated with status 1 (0 minute(s), 0 second(s))
1 error(s), 1 warning(s) (0 minute(s), 0 second(s))


I'm unsure how that's helpful.

oBFusCATed

(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

stahta01

Quote from: DavidNorgren on July 15, 2014, 01:43:09 AM

The build log says:

SNIP

I'm unsure how that's helpful.

It tells me your are trying to use a non MinGW library with MinGW GCC; this might work some of the time but it is not going to work all the time.

The Build Log is also what is needed for you to seek help on another website that knows your Compiler and the Library; but, knows nothing about Code::Blocks.

Tim S.
C Programmer working to learn more about C++.
On Windows 10 64 bit and Windows 11 64 bit.
--
When in doubt, read the CB WiKi FAQ. [url="http://wiki.codeblocks.org"]http://wiki.codeblocks.org[/url]

Vuki

Try linking your program directly with avcodec dll file instead of avcodec.lib.
And you are not compiling FFMPEG library so I don't know why did you put a misleading title.