Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
 help / color / mirror / Atom feed
From: Soft Works <softworkz@hotmail.com>
To: FFmpeg development discussions and patches <ffmpeg-devel@ffmpeg.org>
Subject: Re: [FFmpeg-devel] [PATCH] avcodec/libx264: don't define X264_API_IMPORTS when compiling static
Date: Fri, 20 May 2022 12:07:25 +0000
Message-ID: <DM8P223MB03651DF4F4302E0FAC0F8873BAD39@DM8P223MB0365.NAMP223.PROD.OUTLOOK.COM> (raw)
In-Reply-To: <9d414f9e-0a17-b490-e54c-7ecace981af3@rothenpieler.org>



> -----Original Message-----
> From: ffmpeg-devel <ffmpeg-devel-bounces@ffmpeg.org> On Behalf Of Timo
> Rothenpieler
> Sent: Friday, May 20, 2022 1:38 PM
> To: ffmpeg-devel@ffmpeg.org
> Subject: Re: [FFmpeg-devel] [PATCH] avcodec/libx264: don't define
> X264_API_IMPORTS when compiling static
> 
> On 20/05/2022 12:39, Soft Works wrote:
> >
> >
> >> -----Original Message-----
> >> From: ffmpeg-devel <ffmpeg-devel-bounces@ffmpeg.org> On Behalf Of
> Timo
> >> Rothenpieler
> >> Sent: Friday, May 20, 2022 12:18 PM
> >> To: ffmpeg-devel@ffmpeg.org
> >> Subject: Re: [FFmpeg-devel] [PATCH] avcodec/libx264: don't define
> >> X264_API_IMPORTS when compiling static
> >>
> >> On 20/05/2022 00:52, softworkz wrote:
> >>> From: softworkz <softworkz@hotmail.com>
> >>>
> >>> The definition of X264_API_IMPORTS is required for shared linking
> >>> (when MSVC is used) but it must not be defined in case of static
> >>> builds as is stated in x264.h:
> >>
> >> This doesn't seem right. It's about shared or static linking of
> >> libx264
> >> itself, not ffmpeg.
> >
> > How about some custom macro like DISABLE_X264_API_IMPORTS that one
> > can set when desired?
> >
> > In that case there wouldn't be any logical irritation.
> >
> 
> I'm still quite confused what the actual issue here is.
> Countless libraries ffmpeg depends on need those kind of macros to set
> the correct function import preamble.
> Why does x264 need special treatment? It correctly sets the desired
> flag
> via its pkg-config file.

The current code is 

#if defined(_MSC_VER)
#define X264_API_IMPORTS 1
#endif

Which means that this macro is always set then building with MSVC.
But the macro may only be set when linking to x264.dll, not 
when linking statically to libx264.
(pkg-config can't do anything about that)


This problem was introduced by this change in libx264:

https://code.videolan.org/videolan/x264/-/commit/a615f027ed172e2dd5380e736d487aa858a0c4ff#98b74dd0a8bf575bfdf90bbccf5142a555f06d4f_56_69


Previously, they had this line

#define X264_API __declspec(dllimport)

Which handled the situation automatically by checking whether
it's linked as dll or static lib.

But after that change, you are required to set this 
yourself (as a consumer).

But ffmpeg has no proper condition to set this only when
linking to x264.dll. That's why the current code is
essentially wrong:

#if defined(_MSC_VER)
#define X264_API_IMPORTS 1
#endif

And besides that, I don't think that those things belong into
a code file.


> Is this some "pkg-config does not exist with msvc" thing?


The "official" way of building ffmpeg with MSVC is to run
configure and make from MSYS2/MinGW which then only calls
cl.exe and link.exe from a Visual Studio installation.
In this case pkg-config is used.


I'm working with regular Visual Studio projects, though.
Even dependencies like libx264 are compiled in their own
VS projects.
There's no MSYS2, no make, no pkg-conf involved.


I _think_ that just nobody has ever tried to link libx264
statically when compiling in the "official way", which is
probably rarely used anyway and even more rare that somebody
would bother to link with x264 and once again even more rare
that the one would on top of that decide to link to libx264
statically. That's my guess why nobody has complained about
this during the past 3 years.


Kind regards,
softworkz





_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

  reply	other threads:[~2022-05-20 12:07 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-05-19 22:52 softworkz
2022-05-20  8:49 ` Derek Buitenhuis
2022-05-20  9:36   ` Soft Works
2022-05-20 10:18 ` Timo Rothenpieler
2022-05-20 10:39   ` Soft Works
2022-05-20 11:37     ` Timo Rothenpieler
2022-05-20 12:07       ` Soft Works [this message]
2022-05-20 12:49         ` Derek Buitenhuis
2022-05-20 12:51           ` Derek Buitenhuis
2022-05-20 12:54             ` Soft Works
2022-05-20 13:00               ` Derek Buitenhuis
2022-05-20 13:06                 ` Soft Works
2022-05-20 13:13                   ` Derek Buitenhuis
2022-05-20 13:24                     ` Soft Works
2022-05-20 13:14           ` Soft Works
2022-05-20 15:23 ` [FFmpeg-devel] [PATCH v2] avcodec/libx264: allow to disable definition of X264_API_IMPORTS macro softworkz
2022-05-20 16:22   ` Derek Buitenhuis
2022-05-20 16:34     ` Hendrik Leppkes
2022-05-20 16:37     ` Soft Works
2022-05-20 16:47       ` Derek Buitenhuis
2022-05-20 16:51         ` Martin Storsjö
2022-05-20 16:55           ` Derek Buitenhuis
2022-05-20 17:47             ` Soft Works

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=DM8P223MB03651DF4F4302E0FAC0F8873BAD39@DM8P223MB0365.NAMP223.PROD.OUTLOOK.COM \
    --to=softworkz@hotmail.com \
    --cc=ffmpeg-devel@ffmpeg.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \
		ffmpegdev@gitmailbox.com
	public-inbox-index ffmpegdev

Example config snippet for mirrors.


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git