[FFmpeg-devel] [PATCH] avcodec/libx264: don't define X264_API_IMPORTS when compiling static

Soft Works softworkz at hotmail.com
Fri May 20 12:36:48 EEST 2022



> -----Original Message-----
> From: ffmpeg-devel <ffmpeg-devel-bounces at ffmpeg.org> On Behalf Of
> Derek Buitenhuis
> Sent: Friday, May 20, 2022 10:50 AM
> To: ffmpeg-devel at ffmpeg.org
> Subject: Re: [FFmpeg-devel] [PATCH] avcodec/libx264: don't define
> X264_API_IMPORTS when compiling static
> 
> On 5/19/2022 11:52 PM, softworkz wrote:
> > This commit adds a check for the definition of _LIB which indicates
> > static linking.
> 

> Googling also seems to indicate that this
> definition is no longer available on newer MSVC versions.

Probably we have read the same article on SO ;-)
But it's not true.

When creating a "Static Library" project in Visual Studio 2019, the 
_LIB macro is defined. When creating a dll project, then it is
not defined (instead there is _USRDLL and _WINDLL)

Though, building ffmpeg with the VS project system is not the 
officially supported way for compiling ffmpeg with MSVC, which is 
performing the build on MSYS2/MinGW from which it is calling the 
cl.exe and link.exe binaries directly.

In that case, no _LIB macro is defined which means that this 
commit doesn't affect the official MSVC build method.


> Doesn't this indicate that FFmpeg is being compiled statically, and not
> necessarily that x264 is? 

Correct. Or to be precise, it indicates that libavcodec is compiled 
statically. 

But the thing is:

  1. At this point we are in the world of the VS project system
     (Only)

  2. When - in this case - you would want to link the ffmpeg libs
     statically but x264 as dll, then you'll need to configure this
     specifically for that. Part of this would be to
     define "X264_API_IMPORTS" - but in the project properties,
     not in this code file.

In other words: this is a narrow-scoped fix that doesn't 
affect default ffmpeg build behavior with MSVC. 

The underlying issue most likely applies to the default MSVC
build method as well, but that's out of my scope because I 
don't use it that way and I can't test that.

Thanks,
softworkz


More information about the ffmpeg-devel mailing list