Skip to content
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

Expose SDL2 as sdl2 in pkgconfig to maintian consistency with other distros #141523

Closed
devins2518 opened this issue Oct 13, 2021 · 4 comments
Closed
Labels
0.kind: bug Something is broken

Comments

@devins2518
Copy link
Contributor

Describe the bug

I was attempting to use this zig wrapper for SDL, and compilation failed because ld couldn't find sdl2. At first, I thought this was because of #24744, however, after changing the build script to use SDL2 instead of sdl2, it worked. I assume the library used sdl2 because it is how every other distro exposes the library, and I don't see a reason why Nix needs to change this.

Steps To Reproduce

Steps to reproduce the behavior:

  1. Use this shell.nix
{ pkgs ? import <nixpkgs> { } }:
pkgs.mkShell {
  nativeBuildInputs = with pkgs; [ SDL2 pkgconf ];
  }
  1. Clone and build https://github.com/MasterQ32/SDL.zig

Expected behavior

The line exe.linkSystemLibrary("sdl2"); is able to find SDL2.

Notify maintainers

@cpages

Metadata

Please run nix-shell -p nix-info --run "nix-info -m" and paste the result.

[user@system:~]$ nix-shell -p nix-info --run "nix-info -m"
 - system: `"x86_64-linux"`
 - host os: `Linux 5.10.70, NixOS, 21.11 (Porcupine)`
 - multi-user?: `yes`
 - sandbox: `yes`
 - version: `nix-env (Nix) 2.4pre20210922_bcd73eb`
 - channels(root): `"nixos-21.11pre293730.1ca6b0a0cc3"`
 - nixpkgs: `/nix/store/51b74bw26ldmlj9yi3h7v3scsjl8fdg8-z7qikyiq6zfhxc7k7721z3zcrlpxy9s6-source`

Maintainer information:

# a list of nixpkgs attributes affected by the problem
attribute:
# a list of nixos modules affected by the problem
module:
@devins2518 devins2518 added the 0.kind: bug Something is broken label Oct 13, 2021
@sagehane
Copy link
Contributor

I assume the library used sdl2 because it is how every other distro exposes the library, and I don't see a reason why Nix needs to change this.

Looking at https://archlinux.org/packages/extra/x86_64/sdl2/ and the "Package Contents" section, it seems like Arch Linux also uses SDL2 in uppercase. Installing pkgconf made it so the library name is case insensitive, however. (Meaning I could do something like SdL2)

And judging from the Windows MinGW development library on https://libsdl.org/download-2.0.php, it seems like the upstream uses SDL2 in uppercase too.

$ ls -lA SDL2-2.0.16/x86_64-w64-mingw32/lib
total 15064
drwxr-xr-x 3 plumeus plumeus       18 Oct 14 01:48 cmake
-rw-r--r-- 1 plumeus plumeus 14293518 Aug 11 00:54 libSDL2.a
-rwxr-xr-x 1 plumeus plumeus   483488 Aug 11 00:54 libSDL2.dll.a
-rwxr-xr-x 1 plumeus plumeus     1058 Aug 11 00:54 libSDL2.la
-rw-r--r-- 1 plumeus plumeus   616058 Aug 11 00:54 libSDL2_test.a
-rwxr-xr-x 1 plumeus plumeus      925 Aug 11 00:54 libSDL2_test.la
-rw-r--r-- 1 plumeus plumeus     9422 Aug 11 00:54 libSDL2main.a
-rwxr-xr-x 1 plumeus plumeus      922 Aug 11 00:54 libSDL2main.la
drwxr-xr-x 2 plumeus plumeus       21 Oct 14 01:48 pkgconfig

I haven't checked how other distros deal with this, but I think having it in uppercase should be perfectly reasonable.

@sagehane
Copy link
Contributor

sagehane commented Oct 13, 2021

{ pkgs ? import <nixpkgs> { } }:

pkgs.mkShell {
  buildInputs = with pkgs; [
    SDL2
    pkg-config
  ];
}

Using this shell.nix file for one of my SDL projects allowed the program to compile fine with exe.linkSystemLibrary("sdl2");.

However, pkgconf didn't work. So I presume the problem is that pkgconf doesn't have feature parity with pkg-config on Nix for some reason?

Edit: For clarity, I'm using the master branch of Zig, and not 0.8.1. I don't think it should make a difference, but just thought it was worth mentioning.

@devins2518
Copy link
Contributor Author

Yes, you're right! Changing pkgconf to pkg-config does fix this issue

@sagehane
Copy link
Contributor

I find it strange that pkgconf doesn't work on NixOS when it works fine on Arch Linux. So, I don't know if this issue should be closed yet. Although maybe investigating that should be left up to a different issue?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
0.kind: bug Something is broken
Projects
None yet
Development

No branches or pull requests

2 participants