[FFmpeg-trac] #4764(build system:new): Problems when compiling with msvc toolchain and with other libraries.
FFmpeg
trac at avcodec.org
Fri Aug 7 08:17:39 CEST 2015
#4764: Problems when compiling with msvc toolchain and with other libraries.
-------------------------------------+-------------------------------------
Reporter: | Type: defect
ashegoulding | Priority: wish
Status: new | Version: git-
Component: build | master
system | Blocked By:
Keywords: MSVC | Reproduced by developer: 0
toolchain |
Blocking: |
Analyzed by developer: 0 |
-------------------------------------+-------------------------------------
Summary of the bug:
1. The library tests can't work with cl.exe.
2. Runtime library specification is necessary even for static builds.
(See last section for details)
How to reproduce:
{{{
% vcvarsall.bat
% export LIB="X:\pathto\externlibs\lib;$LIB"
% export INCLUDE="X:\pathto\externlibs\include;$INCLUDE"
# MT, with no msvcrt DLL
% ffmpeg -i input ... output
./configure --toolchain=msvc --enable-gpl --enable-nonfree --enable-nvenc
--enable-libvorbis --enable-libmp3lame --enable-libtheora --enable-libx264
--enable-libx265 --enable-libxvid --enable-static --disable-shared
--disable-debug --extra-cflags="-MD" --extra-cxxflags="-MD" --extra-
ldflags="/nodefaultlib:libcmt.lib" --extra-libs="libmp3lame-static.lib
libtheora_static.lib libxvidcore.lib zlib.lib libmpghip-static.lib
libvorbis_static.lib x265-static.lib libogg_static.lib libx264.lib"
# MD, with msvcrt
./configure --toolchain=msvc --enable-gpl --enable-nonfree --enable-nvenc
--enable-libvorbis --enable-libmp3lame --enable-libtheora --enable-libx264
--enable-libx265 --enable-libxvid --enable-static --disable-shared
--disable-debug --extra-cflags="-MT" --extra-cxxflags="-MT" --extra-
ldflags="/nodefaultlib:msvcrt.lib" --extra-libs="libmp3lame-static.lib
libtheora_static.lib libxvidcore.lib zlib.lib libmpghip-static.lib
libvorbis_static.lib x265-static.lib libogg_static.lib libx264.lib"
}}}
MSVC compiles just fine when it compiles just ffmpeg it self. But when it
comes to compile with other libraries enabled, it goes into chaos.
1. The library tests when using MSVC toolchain
The script builds test programs for enabled libraries to check if they are
available with the given toolchain. For example, to see libmp3lame, it
compiles following code:
{{{
#include <lame/lame.h>
int main(){
lame_set_VBR_quality();
return 0;
}
}}}
specified by configure script line:
{{{
enabled libmp3lame && require "libmp3lame >= 3.98.3" lame/lame.h
lame_set_VBR_quality -lmp3lame
}}}
The problem is, link.exe somehow doesn't know what to link and complains
with error. Yes, the full prototype for the function is:
int lame_set_VBR_quality(lame_global_flags *, float)
Removing these checks(see attachment) solves this problem and the
compilation never fails under the circumstance that libraries are properly
set in LIB and INCLUDE vars.
2. Runtime library links
MSVC toolchain links what runtime library to use when COMPILE TIME, NOT
link time. So /MD and /MT switches are in compiler settings not in linker
settings.
If you have to link MT on your program that links ffmpeg-libs, linking
ffmpeg-libs compiled with /MD won't work because of the external
libraries. Linking will fail. You need to link MT version of ffmpeg-lib
for MT programs or DLLs and vice versa.
As you can see on the "How to reproduce" section, you can compile and link
MT as mentioned and the other libraries that ffmpeg uses.
If someone could fix these problems, we could use use MSVC to compile
ffmepg freely, without using painful mingw toolchains.
--
Ticket URL: <https://trac.ffmpeg.org/ticket/4764>
FFmpeg <https://ffmpeg.org>
FFmpeg issue tracker
More information about the FFmpeg-trac
mailing list