Opened 3 years ago

#9100 new defect

Can't link FFMPEG dynamically to VS 2019 project

Reported by: Maya Owned by:
Priority: normal Component: undetermined
Version: unspecified Keywords:
Cc: Blocked By:
Blocking: Reproduced by developer: no
Analyzed by developer: no

Description

I downloaded the source code of FFMPEG 3.4.8 and built with MSVC as such:
After unzipping, open x86_x64 Cross Tools Command Prompt for VS 2019 and run msys2_shell.cmd. From there, run

./configure --toolchain=msvc --arch=x86_64 --enable-yasm --enable-asm --enable-shared --disable-static

and

make

I then created a new project in VS 2019.
In Properties > C/C++ > General > Additional Include Directories:
(Where all the headers are)

E:\ffmpeg-3.4.8\libavutil
E:\ffmpeg-3.4.8\libavcodec
E:\ffmpeg-3.4.8\libavdevice
E:\ffmpeg-3.4.8\libavfilter
E:\ffmpeg-3.4.8\libavresample
E:\ffmpeg-3.4.8\libpostproc
E:\ffmpeg-3.4.8\libswscale
E:\ffmpeg-3.4.8\libswresample
E:\ffmpeg-3.4.8\libavformat

In Properties > Linker > General > Additional Library Directories:
(Where the .lib files are)

E:\ffmpeg-3.4.8\libavutil
E:\ffmpeg-3.4.8\libavcodec
E:\ffmpeg-3.4.8\libavdevice
E:\ffmpeg-3.4.8\libavfilter
E:\ffmpeg-3.4.8\libavresample
E:\ffmpeg-3.4.8\libpostproc
E:\ffmpeg-3.4.8\libswscale
E:\ffmpeg-3.4.8\libswresample
E:\ffmpeg-3.4.8\libavformat

In Properties > Linker > Input > Additional Dependencies:

avcodec.lib
avdevice.lib
avfilter.lib
avformat.lib
swresample.lib
swscale.lib

For good measure, I copied the .dll files of each library to the Release folder of the project. There is one source file I am trying to build and run:

extern "C" {
#include <libavformat/avformat.h>
}

int main() {
    AVFormatContext* pFormatContext = avformat_alloc_context();
}

The result of 'Build' is as follows:

1>------ Build started: Project: FFMPEG_example, Configuration: Release x64 ------
1>Source.cpp
1>Source.obj : error LNK2001: unresolved external symbol avformat_alloc_context
1>C:\Users\maya.s\source\repos\FFMPEG_example\x64\Release\FFMPEG_example.exe : fatal error LNK1120: 1 unresolved externals
1>Done building project "FFMPEG_example.vcxproj" -- FAILED.
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

Did I do something wrong?

Change History (0)

Note: See TracTickets for help on using tickets.