User forums > Using Code::Blocks

Compiling the FFMPEG library

(1/2) > >>

DavidNorgren:
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;
}
--- End code ---

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:
http://wiki.codeblocks.org/index.php?title=FAQ-Compiling_%28errors%29#Q:_How_do_I_troubleshoot_a_compiler_problem.3F

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

--- End quote ---

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))

--- End code ---

I'm unsure how that's helpful.

oBFusCATed:
http://wiki.codeblocks.org/index.php?title=FAQ-Compiling_%28errors%29#Q:_What_do_I_need_to_know_when_using_3rd_party_libs.3F

stahta01:

--- Quote from: DavidNorgren on July 15, 2014, 01:43:09 am ---
The build log says:

SNIP

I'm unsure how that's helpful.

--- End quote ---

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.

Navigation

[0] Message Index

[#] Next page

Go to full version