Code::Blocks Forums

User forums => Using Code::Blocks => Topic started by: DavidNorgren on July 15, 2014, 01:23:47 am

Title: Compiling the FFMPEG library
Post by: DavidNorgren on July 15, 2014, 01:23:47 am
Hello, I'm trying to compile some simple code using the FFMPEG library:

Code
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.
Title: Re: Compiling the FFMPEG library
Post by: 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 (http://wiki.codeblocks.org/index.php?title=FAQ-Compiling_%28errors%29#Q:_How_do_I_troubleshoot_a_compiler_problem.3F)
Title: Re: Compiling the FFMPEG library
Post by: DavidNorgren on July 15, 2014, 01:43:09 am
http://wiki.codeblocks.org/index.php?title=FAQ-Compiling_%28errors%29#Q:_How_do_I_troubleshoot_a_compiler_problem.3F (http://wiki.codeblocks.org/index.php?title=FAQ-Compiling_%28errors%29#Q:_How_do_I_troubleshoot_a_compiler_problem.3F)

The build log says:

Code
-------------- 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.
Title: Re: Compiling the FFMPEG library
Post by: oBFusCATed on July 15, 2014, 02:23:30 am
http://wiki.codeblocks.org/index.php?title=FAQ-Compiling_%28errors%29#Q:_What_do_I_need_to_know_when_using_3rd_party_libs.3F
Title: Re: Compiling the FFMPEG library
Post by: stahta01 on July 15, 2014, 02:40:04 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.
Title: Re: Compiling the FFMPEG library
Post by: Vuki on July 15, 2014, 07:59:33 pm
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.