3

I am trying to use libavcodec from ffmpeg library in C++ with Visual Studio 2017 Community. I downloaded the latest x64 dev and shared builds from zeranoe (version 20171217), set up include directories and additional libraries in Visual Studio for x64 build, added DLL files from shared package to my PATH.

This is my sample test code:

extern "C" {
#include <libavcodec\avcodec.h>
}
int main() {
    avcodec_register_all();
    AVFrame *pAvFrame = av_frame_alloc();
    av_frame_free(&pAvFrame);
    return 0;
}

The code compiles without problems but when I run the application I see a dialogue window with error message "the procedure entry point for av_frame_alloc could not be located in DLL" (actual message is not in English, this is the translated version).

I tried to set Linker->Optimization->References to /OPT:NOREF as it was advised in the similar questions but it did not help.

Dependency walker shows that av_frame_alloc is exported, "Entry Point" is not bound. A little bit strange is that av_frame_alloc is displayed in both avcodec-58.dll (as red) and avutil-56.dll (as green). Maybe the reason is that the application is trying to get this function from avcodec instead of avutil, but I'm not sure, since I did not check the source code of these libraries.

So the question is how to set up such a simple FFMPEG-based C++ project in VS2017, where I'm wrong?

UPD. 1.

Linker flags: /OUT:"C:\work\code\TestFfmpeg\x64\Release\TestFfmpeg.exe" /MANIFEST /NXCOMPAT /PDB:"C:\work\code\TestFfmpeg\x64\Release\TestFfmpeg.pdb" /DYNAMICBASE "c:\work\dev\ffmpeg-20171217-387ee1d-win64-dev\lib*.lib" "kernel32.lib" "user32.lib" "gdi32.lib" "winspool.lib" "comdlg32.lib" "advapi32.lib" "shell32.lib" "ole32.lib" "oleaut32.lib" "uuid.lib" "odbc32.lib" "odbccp32.lib" /DEBUG:FULL /MACHINE:X64 /OPT:NOREF /PGD:"C:\work\code\TestFfmpeg\x64\Release\TestFfmpeg.pgd" /MANIFESTUAC:"level='asInvoker' uiAccess='false'" /ManifestFile:"x64\Release\TestFfmpeg.exe.intermediate.manifest" /OPT:ICF /ERRORREPORT:PROMPT /NOLOGO /TLBID:1

Aves
  • 31
  • 3
  • What are your linker flags? – Ronald S. Bultje Dec 17 '17 at 19:15
  • I'm using the default settings (except /OPT:NOREF) for empty project in VS2017. I added the linked flags to my qiestion since it is too long for comment – Aves Dec 17 '17 at 19:23
  • `av_frame_alloc` is provided by libavutil (see [libavutil/frame.c](https://github.com/FFmpeg/FFmpeg/blob/9dcecbf04c656ffbfdfbeb7580d701d36071d876/libavutil/frame.c#L150)). Are you linking to libavutil? – Cornstalks Dec 17 '17 at 19:40
  • Yes, avutil.lib is linked to the project, avutil-56.dll is in the path and is loaded by the executable (according to dependency walker). – Aves Dec 17 '17 at 19:44
  • My best suggestion would be to run the relevant cl.exe commands in a terminal or use the logging in MSVC to figure out whether you get any compiler or linker warnings or messages. My guesses would be that it's not linking to the same avutil as what you're loading, or the compiler couldn't find the headers (or used the wrong ones)... – Ronald S. Bultje Dec 18 '17 at 17:22
  • You have to link the libraries in the correct order. – WLGfx Dec 19 '17 at 09:04
  • I tried downgrading to 3.4.1 and this fixed an identical issue for me =( – leander Jan 03 '18 at 14:51
  • Same issue, fixed with the documentation: Read here the point 4.2.1 https://libav.org/documentation/platform.html#Linking-to-Libav-with-Microsoft-Visual-C_002b_002b – TwILeK Dec 19 '18 at 14:36

1 Answers1

0

Try to download the 32-bit version of the .exe file (program). This solved the isse for me for Postman.exe

Prajwal Waingankar
  • 2,534
  • 2
  • 13
  • 20