0

I would like to use ffmpeg for windows and mingw which made me look at:

I was successful at using MSYS according to the documentation / guides above. I followed these steps:

  1. Download ffmpeg source files (from here).
  2. Open MSYS mingw shell
  3. Go to the ffmpeg directory.
  4. Run ./configure --disable-shared --enable-static
  5. Run make -j4
  6. Run make install

But when I am trying to compile g++ -o main main.cpp -IC:\ffmpeg\include -LC:\ffmpeg\lib -lavformat:

#include <iostream>

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

int main() {
    avformat_network_init();
    return 0;
}

I get the following error message: undefined reference to 'avformat_network_init' which I assume is me doing something incorrectly when installing the libraries since if I change the -lavformat to something else I get cannot find -lSOMETHING. The headers are also "found" since I can use for example AVFormatContext* formatContext = NULL; found in avformat.h. The lib directory contains: libavcodec.a libavdevice.a libavfilter.a libavformat.a libavutil.a libswresample.a libswscale.a

Am I missing something obvious or where could the issue be?

darclander
  • 1,526
  • 1
  • 13
  • 35
  • 1
    You don't need to compile it by hand, and there's barely any reason to use the old MSYS1. Get [MSYS2](https://stackoverflow.com/q/30069830/2752075) and install ffmpeg as a prebuilt package. – HolyBlackCat Jul 24 '23 at 20:26
  • @HolyBlackCat it does indeed work to install & compile via MSYS2 but I already have a complete installation of mingw on my computer. Can I just move the include and lib folders from the MSYS2 version and make it work that way? (Sorry I am fairly new to these kind of things) – darclander Jul 24 '23 at 21:00
  • 1
    Just no. It could give you some hard to debug issues. MSYS2 is one of the few sane MinGW distributions out there (one of the few that ships an up-to-date compiler, and I believe the only one with a package manager). I would uninstall any existing versions of MinGW you have. – HolyBlackCat Jul 24 '23 at 21:05
  • @HolyBlackCat this does indeed work as a "workaround" I suppose? I have followed your advice and will be working with the MSYS2 version of mingw in the future. But I leave the question as it is because I feel like the ffmpeg windows documentation is rather lacking (unless I missed something). – darclander Jul 25 '23 at 14:00
  • 1
    Since MSYS2 is open-source, you can look at the steps they do to build it, here: https://github.com/msys2/MINGW-packages/tree/master/mingw-w64-ffmpeg – HolyBlackCat Jul 25 '23 at 14:14

0 Answers0