Author Topic: Compiling the FFMPEG library  (Read 11318 times)

Offline DavidNorgren

  • Single posting newcomer
  • *
  • Posts: 2
Compiling the FFMPEG library
« 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.

Offline stahta01

  • Lives here!
  • ****
  • Posts: 7591
    • My Best Post
C Programmer working to learn more about C++ and Git.
On Windows 7 64 bit and Windows 10 64 bit.
--
When in doubt, read the CB WiKi FAQ. http://wiki.codeblocks.org

Offline DavidNorgren

  • Single posting newcomer
  • *
  • Posts: 2
Re: Compiling the FFMPEG library
« Reply #2 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

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.

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
(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!]

Offline stahta01

  • Lives here!
  • ****
  • Posts: 7591
    • My Best Post
Re: Compiling the FFMPEG library
« Reply #4 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.
C Programmer working to learn more about C++ and Git.
On Windows 7 64 bit and Windows 10 64 bit.
--
When in doubt, read the CB WiKi FAQ. http://wiki.codeblocks.org

Offline Vuki

  • Multiple posting newcomer
  • *
  • Posts: 41
Re: Compiling the FFMPEG library
« Reply #5 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.