1

As the title says, I have been trying to get ffmpeg/libav libraries to work in MSVC++ 2010. However, I keep running in the following error while coding on debug mode.

code:

extern "C" 
{
    #ifndef __STDC_CONSTANT_MACROS
    #define __STDC_CONSTANT_MACROS
    #endif
    #include <libavcodec\avcodec.h>
    #include <libavformat\avformat.h>
    #include <libswscale\swscale.h>
    #include <libavutil\avutil.h>
}
int main( int argc, char* argv[] ) 
{
    av_register_all();
    return 0;
}

console:

1>------ Build started: Project: ffmpeg, Configuration: Debug Win32 ------
1>ffmpeg.obj : error LNK2019: unresolved external symbol _av_register_all referenced in       function _main
1>C:\Users\okki\documents\visual studio 2010\Projects\ffmpeg\Debug\ffmpeg.exe : fatal    error LNK1120: 1 unresolved externals
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

I used zeranoe's latest build git-56ba331 (2013-05-14).

And I have tried the following to fix this:

  • configuring the project to look for both the x64 and x86 libraries.
  • Add the DLLs from the 'shared' package to both library folders.
  • Add the library directory to both the linker options and VC++ Directories.

I have been stuck on this for a while, and any suggestion can help. If any extra info is needed I will happily provide.

T3 H40
  • 2,326
  • 8
  • 32
  • 43
Yvo Götz
  • 15
  • 1
  • 3
  • Possible duplicate of [What is an undefined reference/unresolved external symbol error and how do I fix it?](http://stackoverflow.com/questions/12573816/what-is-an-undefined-reference-unresolved-external-symbol-error-and-how-do-i-fix) – Niall Oct 09 '15 at 05:18

1 Answers1

4

Download latest files from http://ffmpeg.zeranoe.com/builds/win32/shared/ and from http://ffmpeg.zeranoe.com/builds/win32/dev/ (Shared and Dev) and unpacked them into ffmpeg\shared and ffmpeg\dev respectively

Create a new console project, set the value of "Additional Include Directory" to ffmpeg\dev\include, "Additional Library Directories" to ffmpeg\dev\lib\

Add to your code

# pragma comment (lib, "avformat.lib")

(In real projects you will need at least the files avutil.lib, avcodec.lib)

To run the program, copy the *.dll files from the ffmpeg\shared\bin to output folder

pogorskiy
  • 4,705
  • 1
  • 22
  • 21