I would like to use ffmpeg for windows and mingw which made me look at:
- https://trac.ffmpeg.org/wiki/CompilationGuide/MinGW
- https://dev.to/codesomething/installing-mingw-w64-on-windows-and-fixing-the-weird-file-downloaded-incorrectly-error-4b85
I was successful at using MSYS according to the documentation / guides above. I followed these steps:
- Download ffmpeg source files (from here).
- Open
MSYS mingw shell - Go to the ffmpeg directory.
- Run
./configure --disable-shared --enable-static - Run
make -j4 - 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?