zmwangx / rust-ffmpeg

Safe FFmpeg wrapper.
Do What The F*ck You Want To Public License
1.2k stars 195 forks source link

Static linking #172

Open thewh1teagle opened 6 months ago

thewh1teagle commented 6 months ago

I use ffmpeg_next in ruscribe And I build it inside msys2 environment (ucrt64) It works well, but if I want to use it outside of the environment (in windows itself) there's missing DLL's which it needs to load dynamically, I would like to link them staticlly so I can ship single exe to users without extra files.

The error looks like image

Missing DLL(s) are: avdevice-60.dll avfilter-9.dll avformat-60.dll avcodec-60.dll The are in C:\msys64\ucrt64\bin\ Coming from the package: mingw-w64-ucrt-x86_64-ffmpeg

thewh1teagle commented 6 months ago

Tried the following in msys2 inside ucrt64 terminal

NAME=ffmpeg-n4.4-latest-win64-gpl-shared-4.4
if [ ! -d shared/$NAME ]; then
    wget -q --show-progress https://github.com/BtbN/FFmpeg-Builds/releases/download/latest/$NAME.zip -O shared.zip
    unzip shared.zip -d shared
fi

export FFMPEG_DIR="$(pwd)/shared/$NAME"
echo "\$FFMPEG_DIR is $FFMPEG_DIR"

export PKG_CONFIG_PATH=$PKG_CONFIG_PATH:$FFMPEG_DIR/lib/pkgconfig
echo "\$PKG_CONFIG_PATH is $PKG_CONFIG_PATH"
export PKG_CONFIG_SYSTEM_INCLUDE_PATH="$FFMPEG_DIR/libavcodec:$FFMPEG_DIR/libavdevice:$FFMPEG_DIR/libavfilter:$FFMPEG_DIR/libavformat:$FFMPEG_DIR/libavutil:$FFMPEG_DIR/libpostproc:$FFMPEG_DIR/libswresample:$FFMPEG_DIR/libswscale"
echo "\$PKG_CONFIG_SYSTEM_INCLUDE_PATH is $PKG_CONFIG_SYSTEM_INCLUDE_PATH"
export LIBCLANG_PATH=$MINGW_PREFIX/bin
cargo build

It almost finish compile and then

error: could not find native static library `avcodec`, perhaps an -L flag is missing?