[FFmpeg-devel] [PATCH] Shared library support for MSVC build.

jamal jamrial at gmail.com
Wed Oct 3 23:01:03 CEST 2012

On 03/10/12 2:35 AM, Ronald S. Bultje wrote:> Hi,
> On Tue, Oct 2, 2012 at 8:59 PM, jamal <jamrial at gmail.com> wrote:
>> You're doing what you mentioned you wanted to avoid the other day: Create a header for essentially a single purpose/platform and include it in those files that would require it.
>> __declspec() is an attribute, so you could instead add it to libavutil/attributes.h to more or less avoid that, since it's a widely used header.
> Can do, but then I'd need to create a libavcodec/attributes.h also,
> which I thought was kind of weird, i.e. you'd have
> libavutil/attributes.h with all general attributes, and then
> libavcodec/attributes.h with the symbol-stuff specific to libavcodec.
> But sure if you prefer, I can do that too...
> Ronald

Can't you use libavutil/attributes.h for both cases instead of creating a new header in libavcodec?

That aside:

> @@ -3078,11 +3079,13 @@ case $target_os in
>          shlibdir_default="$bindir_default"
>          SLIBPREF=""
>          SLIBSUF=".dll"
> +        LIBPREF=""
> +        LIBSUF=".lib"
>          dlltool="${cross_prefix}dlltool"
>          if check_cmd lib.exe -list; then
> -            SLIB_EXTRA_CMD='-lib.exe /machine:$(LIBTARGET) /def:$$(@:$(SLIBSUF)=.def) /out:$(SUBDIR)$(SLIBNAME:$(SLIBSUF)=.lib)'
> +            SLIB_EXTRA_CMD='-lib.exe -machine:$(LIBTARGET) -def:$$(@:$(SLIBSUF)=.def) -out:$(SUBDIR)$(SLIBNAME:$(SLIBSUF)=.lib)'
>              if enabled x86_64; then
>                  LIBTARGET=x64
>              fi
> @@ -3092,8 +3095,8 @@ case $target_os in
> -        SHFLAGS='-shared -Wl,--output-def,$$(@:$(SLIBSUF)=.def) -Wl,--out-implib,$(SUBDIR)lib$(SLIBNAME:$(SLIBSUF)=.dll.a) -Wl,--enable-runtime-pseudo-reloc -Wl,--enable-auto-image-base'
> +        SHFLAGS='-dll -def:$$(@:$(SLIBSUF)=.def) -implib:$(SUBDIR)lib$(SLIBNAME:$(SLIBSUF)=.dll.a)'
>          objformat="win32"
>          ranlib=:
>          enable dos_paths

This breaks compilation with Mingw. The change to SHFLAGS generates this error:

LD      libavutil/avutil-51.dll
i686-w64-mingw32-gcc.exe: error: unrecognized command line option '-implib:libavutil/libavutil.dll.a'
make: *** [libavutil/avutil-51.dll] Error 1

And the change to SLIB_INSTALL_EXTRA_LIB generates this error during install (After undoing the change to SHFLAGS so the libraries actually compile):

$ make install
INSTALL libavdevice/avdevice.lib
INSTALL libavdevice/avdevice.dll
STRIP   install-libavdevice-shared
INSTALL libavdevice/avdevice.dll
INSTALL libavdevice/avdevice.dll
install: cannot stat `libavdevice/libavdevice.dll': No such file or directory
make: *** [install-libavdevice-shared] Error 1

Also, by changing LIBSUF to ".lib" you're making the build system overwrite the static libraries created with gnu ar with the shared ones created with lib.exe/dlltool (Or skipping the creation of static libraries altogether if lib.exe/dlltool was run first, since a .lib file would already exist)


More information about the ffmpeg-devel mailing list