-
-
Notifications
You must be signed in to change notification settings - Fork 524
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add Cflags.private to support static linking on Windows #162
Comments
@eli-schwartz any comment on this? I don't see support for this in meson. |
Is this guaranteed to work? What if Cflags.private get passed after Cflags? |
That's the whole point, it doesn't work otherwise... W/ the patched MSYS2 package:
|
Eh, sorry, I obviously meant before, not after. Is it documented pkg-config behaviour that we could rely on?
If yes, neat solution!
|
[1] https://www.msys2.org/docs/pkgconfig/#cflagsprivate-static-libraries |
Il giorno ven 28 feb 2025 alle 14:05:34 -08:00:00, Miloš Komarčević
***@***.***> ha scritto:
Cflags.private is not a documented feature, and is AFAIK only
implemented (and in this particular order) by pkgconf [1], and not by
pkg-config.
Did a small research, and this is actually documented in the pc(5)
manual page (part of pkgconf). You can read it here:
<https://www.mankier.com/5/pc>.
Still, the field is only documented as being used for static
compilation. No guarantee of being ordered after the Cflags field is
made.
That's ok though, as this is of interest only for Windows DLLs vs
static libs, and on Windows dev environnements mostly/exclusively
pkgconf is available/used (MSYS2, vcpkg, etc.).
pkgconf is for sure used by the vast majority (all?) of Linux
distributions, but on Windows I wouldn't be so sure. Yeah, there's
pkgconf, but there are also:
- Strawberry perl pkg-config: https://strawberryperl.com
- u-config (part of w64devkit): https://github.com/skeeto/u-config
- CMake's new native .pc resolver:
https://cmake.org/cmake/help/latest/command/cmake_pkg_config.html
- The original FreeDesktop implementation, pkgconfiglite, and probably
others, as outlined in the top StackOverflow question about installing
pkg-config on Windows:
https://stackoverflow.com/questions/1710922/how-to-install-pkg-config-in-windows
I see the following possible alternative solutions:
1. Ask pkgconf upstream to document the behaviour you're currently
observing of having Cflags.private apply after Cflags, so that it
doesn't go away in the future, or
2. Do not rely on the order of options, but define a thing like
-DINI_STATIC_LIB which overrides -DINI_SHARED_LIB in the C code itself.
|
Cflags.private: -UINI_SHARED_LIB
is needed to support both shared and static linking on Windows with a single .pc file.See e.g. https://stackoverflow.com/a/66079443
The text was updated successfully, but these errors were encountered: