Yvo Götz
Yvo Götz

Reputation: 15

Using ffmpeg static libraries in an visual studio explress C++ 2010 project

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:

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

Upvotes: 1

Views: 6181

Answers (1)

pogorskiy
pogorskiy

Reputation: 4815

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

Upvotes: 4

Related Questions