问题
I'm attempting to build some video-reading code around libavformat. After getting the compiled DLLs and .lib
files here, I go to build my code, and the linker can't find any of the libavformat symbols even though I've linked in the provided .lib
files.
Inspecting libavformat.lib
with dumpbin -headers
reveals that it exports the desired functions with an underscore prefix. For example, while I want to call avformat_open_input
, the .lib file gives _avformat_open_input
.
Why is this, and why can't I link the precompiled dlls?
回答1:
You need to do following all tasks to use libav
with MSVC++
. First goto Zeranoe
- Download
Shared
Version, Copy all.dll
files frombin
folder and paste them in the output directory whereexe
will be generated. - Download
Developer
Version, Copy all.lib
files fromlib
folder and paste them with your main c++ file is located (e.g.Folder-1\Folder-2
WhereFolder-1
has the.sln
file so you have to put.lib
files inFolder-2
) - From
Developer
Version you downloaded in Step 2 copy all directories frominclude
folder and paste them in Folder-2 (See details about Folder-2 in step 2) - Download inttypes.h and stdint.h, save it on this location
C:\Program Files\Microsoft Visual Studio 10.0\VC\include\
folder. - To include header files use following syntax
You have to use this extern
because libav
is a C
library.
extern "C" {
#include "libavcodec/avcodec.h"
#include "libavdevice/avdevice.h"
#include "libavfilter/avfilter.h"
#include "libavformat/avformat.h"
#include "libavutil/avutil.h"
}
回答2:
Fetch the 32-bit libraries and you should be fine :) Your application platform has to match the libraries used (and vica versa).
回答3:
What about compiling it as a .lib static library?
来源:https://stackoverflow.com/questions/11301864/linking-libavformat-in-visual-studio-2010