3

I just downloaded the dev package for ffmpeg and was setting up headers and libraries for use. I'm using Visual C++ 2013 and I added the path of the ffmpeg header files and libs. I linked to every single lib file in the ffmpeg lib folder and apparently none of them matched av_register_all and avformat_open_input.

Here's the output from trying to build:

1>------ Build started: Project: ffmpeg_learning, Configuration: Debug Win32 ------
1>  ffmpeg_learning.cpp
1>ffmpeg_learning.obj : error LNK2019: unresolved external symbol _av_register_all referenced in function _main
1>ffmpeg_learning.obj : error LNK2019: unresolved external symbol _avformat_open_input referenced in function _main
1>c:\users\edward severinsen\documents\visual studio 2013\Projects\ffmpeg_learning\Debug\ffmpeg_learning.exe : fatal error LNK1120: 2 unresolved externals
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

Here's my code:

#include "stdafx.h"

extern "C"
{
    #include <libavcodec/avcodec.h>
    #include <libavformat/avformat.h>
    #include <libswscale/swscale.h>
}

#pragma comment(lib, "avcodec.lib")
#pragma comment(lib, "avformat.lib")
#pragma comment(lib, "swscale.lib")
#pragma comment(lib, "avdevice.lib")
#pragma comment(lib, "avutil.lib")
#pragma comment(lib, "avfilter.lib")
#pragma comment(lib, "postproc.lib")
#pragma comment(lib, "swresample.lib")

int main(int argc, char* argv[])
{
    av_register_all();

    AVFormatContext* pFormatCtx = NULL;

    //Open video file
    if (avformat_open_input(&pFormatCtx, argv[1], NULL, 0))
    {
        //Couldn't open the file
        return -1;
    }

    return 0;
}

I have no idea what I'm missing. Any help would be much appreciated. Thanks.

Iharob Al Asimi
  • 52,653
  • 6
  • 59
  • 97

1 Answers1

1

Based on the information given I can only make general suggestions. I will try to indicate how relatively important they may be.

1) VC++ 2013 may be a little outdated. This is likely the least of your problems. You can always try building a release of FFMPEG on Linux, or OSX, in that order. It builds most easily on Linux. Then you can "port" or duplicate the steps in the your Windows build environment. You can also try MSYS2 to create a build environment on Windows that mimics Linux.

2) Make sure to get the latest stable releases of FFMPEG. When reporting problems, make sure to always mention the version, and show the output of the ffmpeg command.

3) Based on the above it looks like you may have a Library Version mismatch problem. It appears to only have found two missing symbols. VisualC++ should have tools like "strings", "objdump", and "nm", that will let you look at the contents of Library files to see if you actually have the desired symbols.

  • 1
    The problem was that `avformat-58.dll` as well as other dependencies were not included with the dev package. So I had to also download the shared package to get the extra libraries. After adding those libraries to the bin directory of my program it began working properly. – Edward Severinsen Feb 27 '18 at 15:50