简体   繁体   中英

Linking libavformat in Visual Studio 2010

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?

You need to do following all tasks to use libav with MSVC++ . First goto Zeranoe

  1. Download Shared Version, Copy all .dll files from bin folder and paste them in the output directory where exe will be generated.
  2. Download Developer Version, Copy all .lib files from lib folder and paste them with your main c++ file is located (eg Folder-1\\Folder-2 Where Folder-1 has the .sln file so you have to put .lib files in Folder-2 )
  3. From Developer Version you downloaded in Step 2 copy all directories from include folder and paste them in Folder-2 (See details about Folder-2 in step 2)
  4. Download inttypes.h and stdint.h , save it on this location C:\\Program Files\\Microsoft Visual Studio 10.0\\VC\\include\\ folder.
  5. 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"
}

提取32位库,就可以了:)您的应用程序平台必须匹配所使用的库(反之亦然)。

如何将其编译为.lib静态库?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM