Closed davexunit closed 1 week ago
That sounds like it's doing the right thing here. If you're linking directly to those libraries, then your built library has those dependencies, and if they're not installed, SDL won't run.
Hi @slouken, the libraries are installed, it's just that Guix (and also Nix) do not conform to the FHS and use the runpath mechanism to hardcode the path to the libraries. Thus there's no need to search for them with pkgconfig. It would be very cumbersome to have to drag those .pc
files along in this context, and something that is not needed for other C libraries packaged in Guix. I'm not a CMake nor a pkgconfig expert, but I do know that SDL2 does the right thing without any intervention here. Perhaps it's not an issue with Requirements.private
but Libs.private
. I will poke around a bit more.
It sounds like you want to include a patch in your distro packaging to prevent including dependencies in sdl3.pc
. It doesn't sound like that's a change we generally want to make upstream.
Requires.private
, Cflags.private
and Libs.private
are only used when you want to link to a static SDL3 library. By adding --static
to the call to pkg-config
/pkgconf
.
Reading pkgconf's implementation of the autoconf macros, --static
is only added when using PKG_CHECK_MODULES_STATIC
instead of PKG_CHECK_MODULES
.
FWIW pkgconfig is being invoked like this: pkg-config --short-errors --print-errors --cflags --libs sdl3
. I'll continue debugging under the assumption that there's something on my end that's wrong.
Requires.private
,Cflags.private
andLibs.private
are only used when you want to link to a static SDL3 library.
That's not 100% true. Requires.private
and Cflags.private
are also used for pkg-config --cflags
during dynamic linking, because pkg-config/pkgconf can't tell the difference between these two scenarios:
#include <X11/Xlib.h>
in /usr/include/gtk-3.0/gdk/gdkx.h
so it can declare functions like gdk_x11_window_get_xid()
)So it pessimistically assumes the stronger dependency (the first one). This is actually unnecessarily strict for SDL, but pkg-config/pkgconf doesn't have enough information to know that for sure.
.private
libraries are not included in pkg-config --libs
, to avoid "overlinking". For example, when you build a SDL game, the game doesn't need to be linked to -lX11
unless it explicitly calls libX11 functions itself. libX11 gets loaded into its process space indirectly, via SDL's DT_NEEDED
ELF header, or the equivalent in non-ELF environments.
The only two solutions I'm aware of for this are:
${prefix}
, this is just a matter of adding dependencies, for example in Debian I made libsdl3-dev
depend on libx11-dev
and many others.PKG_CONFIG_PATH
. Your distro presumably already has a mechanism to do this, somehow, otherwise you wouldn't be able to package (for example) GTK.alsa
or x11
in Requires.private
, move them to being a library name like -lasound
or -lX11
in Libs.private
.Thanks for helping me get my head on straight to debug this properly. The differences between the generated .pc
files between SDL2 and SDL3 threw me for a loop, but your replies helped me get a better understanding of what I was looking at. You're all right that sdl3.pc
is fine just the way it is. The pattern we need to use in Guix to handle situations where a library depends on the .pc
files of their dependencies is to mark those dependencies as propagated so PKG_CONFIG_PATH
can be set correctly. Thanks again! Closing.
I'm working with commit 596fcfa6c4fd20e5a952c0a1b0147f2fa9f69198 from main in anticipation of SDL3's official release (for both packaging in the Guix Linux distro and writing language wrappers) and having trouble with the
sdl3.pc
pkgconfig file being generated.Relevant context: I'm compiling with GCC 11.4.0 with the following CMake flags so that SDL links against specific libraries rather than trying to dlopen at runtime:
Here's the contents of my
sdl3.pc
:Should the
Requires.private
line have all these things in it if mylibSDL3.so
is linked against all the relevant libraries? For contrast, thesdl2.pc
file on my system (from upstream Guix'ssdl2
package, built with the equivalent-D
flags) is:Note the empty
Requires.private
line.This difference becomes significant when I try to bootstrap an autotools project with this in
configure.ac
:When building in an environment with
sdl3.pc
but not the.pc
files of dependencies onPKG_CONFIG_PATH
, I get an error:The equivalent check for SDL2 works fine because it doesn't need all the dependent
.pc
files. This is the property I'd like to have for SDL3, as well. Is there an additional CMake flag I should be using or something? I took a look at the build system files but if it's there I missed it.(p.s: Having a great time with SDL3 so far. The GPU API is a very welcomed addition!)