[FFmpeg-devel] [PATCH] Proper support for building MSVC import libraries

Ramiro Ribeiro Polla ramiro
Sat Jul 21 00:31:28 CEST 2007


 wrote:
> Ramiro Polla <ramiro at lisha.ufsc.br> writes:
>
>   
>> Hello,
>>
>> Currently, MSVC import libraries are created for dlls if the lib
>> program exists on MinGW's PATH (with the wrong name, since BUILDSUF is
>> not respected).
>> IMO, Makefile commands don't belong in configure (such as
>> SLIB_INSTALL_EXTRA_CMD).
>>
>> Attached patch adds an option to configure and puts Makefile commands
>> in common.mak.
>>
>> Ramiro Polla
>> Index: configure
>> ===================================================================
>> --- configure	(revision 9765)
>> +++ configure	(working copy)
>> @@ -65,6 +65,7 @@
>>    echo "  --enable-static          build static libraries [default=yes]"
>>    echo "  --disable-static         do not build static libraries [default=no]"
>>    echo "  --enable-shared          build shared libraries [default=no]"
>> +  echo "  --enable-msvc-implib     build MSVC import libs for dlls [default=no]"
>>     
>
> Why this option?
>   

Because not every MinGW user wants to build MSVC import libs. But not 
everyone wants pkgconfig files either, and they always get installed. So 
it's also fine if this option doesn't exist. Instead, the 'lib' program 
should be checked for in a common win32 specific section in configure.

>   
>> @@ -1157,9 +1159,10 @@
>>      EXESUF=".exe"
>>      SLIBNAME_WITH_VERSION='$(SLIBPREF)$(NAME)-$(LIBVERSION)$(SLIBSUF)'
>>      SLIBNAME_WITH_MAJOR='$(SLIBPREF)$(NAME)-$(LIBMAJOR)$(SLIBSUF)'
>> -    SLIB_EXTRA_CMD="-lib /machine:i386 /def:\$(@:${SLIBSUF}=.def)"
>> -    SLIB_INSTALL_EXTRA_CMD="-install -m 644 \$(SLIBNAME_WITH_MAJOR:\$(SLIBSUF)=.lib) \"\$(shlibdir)/\$(SLIBNAME_WITH_MAJOR:\$(SLIBSUF)=.lib)\""
>> -    SHFLAGS="-shared -Wl,--output-def,\$(@:${SLIBSUF}=.def),--out-implib,lib\$(SLIBNAME:\$(SLIBSUF)=.dll.a) -Wl,--enable-runtime-pseudo-reloc -Wl,--enable-auto-image-base"
>> +    MSVC_IMPLIB='$(SLIBNAME_WITH_MAJOR:.dll=.lib)'
>> +    enabled msvc_implib &&
>> +        MSVC_IMPLIB_SHFLAGS='-Wl,--output-def,$(MSVC_IMPLIB:.lib=.def)'
>> +    SHFLAGS='-shared $(MSVC_IMPLIB_SHFLAGS) -Wl,--out-implib,lib$(SLIBNAME:$(SLIBSUF)=.dll.a) -Wl,--enable-runtime-pseudo-reloc -Wl,--enable-auto-image-base'
>>     
>
> Is this really correct?  That unconditional --out-imlib option looks a
> little fishy to my untrained eye.
>
> BTW, am I the only one who thinks that chunk is really ugly to look at?
>
>   

Take a closer look. --out-implib is already there. I also think that is 
really ugly to look at. But then, again, MinGW support is an ugly hack, 
and you just don't bother about it more because it's enclosed in a small 
section in configure (which you probably skip every time you scroll 
through configure=). And that's exactly why I'm trying to clean it up. A 
proper Makefile target can be made with dlltool instead of --out-implib, 
which is the subject for another patch I'm working on. MinGW support is 
wrong the way it is.

>>      enabled network && add_extralibs -lws2_32
>>      ;;
>>    cygwin*)
>> @@ -1930,8 +1933,10 @@
>>    echo "SLIBNAME=${SLIBNAME}" >> config.mak
>>    echo "SLIBNAME_WITH_VERSION=${SLIBNAME_WITH_VERSION}" >> config.mak
>>    echo "SLIBNAME_WITH_MAJOR=${SLIBNAME_WITH_MAJOR}" >> config.mak
>> -  echo "SLIB_EXTRA_CMD=${SLIB_EXTRA_CMD}" >> config.mak
>> -  echo "SLIB_INSTALL_EXTRA_CMD=${SLIB_INSTALL_EXTRA_CMD}" >> config.mak
>> +  enabled msvc_implib &&
>> +    echo "BUILD_MSVC_IMPLIB=yes" >> config.mak
>>     
>
> Settings like this one should be done the generic way.
>   

I don't see how this differs from:
if enabled shared; then
  echo "BUILD_SHARED=yes" >> config.mak

Could you, please, be more specific?

>   
>> +  echo "MSVC_IMPLIB=${MSVC_IMPLIB}" >> config.mak
>> +  echo "MSVC_IMPLIB_SHFLAGS=${MSVC_IMPLIB_SHFLAGS}" >> config.mak
>>  fi
>>  echo "LIB_INSTALL_EXTRA_CMD=${LIB_INSTALL_EXTRA_CMD}" >> config.mak
>>  echo "EXTRALIBS=$extralibs" >> config.mak
>> Index: common.mak
>> ===================================================================
>> --- common.mak	(revision 9765)
>> +++ common.mak	(working copy)
>> @@ -19,7 +19,7 @@
>>  STATIC_OBJS := $(OBJS) $(STATIC_OBJS)
>>  SHARED_OBJS := $(OBJS) $(SHARED_OBJS)
>>
>> -all: $(EXTRADEPS) $(LIB) $(SLIBNAME)
>> +all: $(EXTRADEPS) $(LIB) $(SLIBNAME) $(MSVC_IMPLIB)
>>
>>  $(LIB): $(STATIC_OBJS)
>>  	rm -f $@
>> @@ -31,8 +31,10 @@
>>
>>  $(SLIBNAME_WITH_MAJOR): $(SHARED_OBJS)
>>  	$(CC) $(SHFLAGS) $(LDFLAGS) -o $@ $^ $(EXTRALIBS) $(EXTRAOBJS)
>> -	$(SLIB_EXTRA_CMD)
>>
>> +$(MSVC_IMPLIB): $(SLIBNAME_WITH_MAJOR)
>> +	lib /machine:i386 /def:$(@:.lib=.def)
>> +
>>  %.o: %.c
>>  	$(CC) $(CFLAGS) $(LIBOBJFLAGS) -c -o $@ $<
>>
>> @@ -64,6 +66,9 @@
>>  ifeq ($(BUILD_STATIC),yes)
>>  INSTLIBTARGETS += install-lib-static
>>  endif
>> +ifeq ($(BUILD_MSVC_IMPLIB),yes)
>> +INSTLIBTARGETS += install-lib-msvc-implib
>> +endif
>>
>>  install: install-libs install-headers
>>
>> @@ -77,13 +82,15 @@
>>  		ln -sf $(SLIBNAME_WITH_VERSION) $(SLIBNAME_WITH_MAJOR)
>>  	cd "$(shlibdir)" && \
>>  		ln -sf $(SLIBNAME_WITH_VERSION) $(SLIBNAME)
>> -	$(SLIB_INSTALL_EXTRA_CMD)
>>
>>  install-lib-static: $(LIB)
>>  	install -d "$(libdir)"
>>  	install -m 644 $(LIB) "$(libdir)"
>> -	$(LIB_INSTALL_EXTRA_CMD)
>>
>> +install-lib-msvc-implib: $(MSVC_IMPLIB)
>> +	install -d "$(libdir)"
>> +	install -m 644 $(MSVC_IMPLIB) "$(libdir)"
>>     
>
> install-lib-static: $(LIB) $(MSVC_IMPLIB)
> 	...
>
> Or some variation thereof.  I don't recall the exact semantics of
> these targets.
>
>   

Right, this can be simplified. I'll investigate further for the next patch.

Ramiro Polla




More information about the ffmpeg-devel mailing list