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

sdl2-sys with "use-pkgconfig" feature in windows uses path delimiter ":" instead of ";" #1448

Open
themazeimade opened this issue Dec 12, 2024 · 0 comments

Comments

@themazeimade
Copy link

Hi
My enviroment consists of windows11 and rustrover. I have downloaded the sdl2 and sdl2-image libraries from scoop. When I try compile my SLD2 project with the "use-pkgconfig" feature It fails while compiling the sdl2-sys library.

I checked if pkg-config can find the SDL2 library .pc file, and it does.

C:\Users\Usuario>pkg-config --list-all 
sdl2 sdl2 - Simple DirectMedia Layer is a cross-platform multimedia library designed to provide low level access to audio, keyboard, mouse, joystick, 3D hardware via OpenGL, and 2D video framebuffer.

I also checked my PKG_CONFIG_PATH and it's also correct. They contain the .pc file.
image

The error I get is this

error: failed to run custom build command for `sdl2-sys v0.37.0`
note: To improve backtraces for build dependencies, set the CARGO_PROFILE_DEV_BUILD_OVERRIDE_DEBUG=true environment variable to enable debug information generation.
Caused by:
  process didn't exit successfully: `C:\Users\Usuario\RustroverProjects\untitled\target\debug\build\sdl2-sys-d5bb1b9a2e6a9aa6\build-script-build` (exit code: 101)
  --- stdout
  cargo:include=C:\Users\Usuario\.cargo\registry\src\index.crates.io-6f17d22bba15001f\sdl2-sys-0.37.0\SDL\include
  cargo:rerun-if-env-changed=SDL2_NO_PKG_CONFIG
  cargo:rerun-if-env-changed=PKG_CONFIG_x86_64-pc-windows-msvc
  cargo:rerun-if-env-changed=PKG_CONFIG_x86_64_pc_windows_msvc
  cargo:rerun-if-env-changed=HOST_PKG_CONFIG
  cargo:rerun-if-env-changed=PKG_CONFIG
  cargo:rerun-if-env-changed=PKG_CONFIG_PATH_x86_64-pc-windows-msvc
  cargo:rerun-if-env-changed=PKG_CONFIG_PATH_x86_64_pc_windows_msvc
  cargo:rerun-if-env-changed=HOST_PKG_CONFIG_PATH
  cargo:rerun-if-env-changed=PKG_CONFIG_PATH
  cargo:rerun-if-env-changed=PKG_CONFIG_LIBDIR_x86_64-pc-windows-msvc
  cargo:rerun-if-env-changed=PKG_CONFIG_LIBDIR_x86_64_pc_windows_msvc
  cargo:rerun-if-env-changed=HOST_PKG_CONFIG_LIBDIR
  cargo:rerun-if-env-changed=PKG_CONFIG_LIBDIR
  cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR_x86_64-pc-windows-msvc
  cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR_x86_64_pc_windows_msvc
  cargo:rerun-if-env-changed=HOST_PKG_CONFIG_SYSROOT_DIR
  cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR
  --- stderr
  thread 'main' panicked at C:\Users\Usuario\.cargo\registry\src\index.crates.io-6f17d22bba15001f\sdl2-sys-0.37.0\build.rs:51:10:
  called `Result::unwrap()` on an `Err` value: 
  pkg-config exited with status code 1
  > PKG_CONFIG_PATH=C:\Users\Usuario\scoop\apps\sdl2\current\lib\pkgconfig PKG_CONFIG_ALLOW_SYSTEM_LIBS=1 PKG_CONFIG_ALLOW_SYSTEM_CFLAGS=1 pkg-config --libs --cflags sdl2
  The system library `sdl2` required by crate `sdl2-sys` was not found.
  The file `sdl2.pc` needs to be installed and the PKG_CONFIG_PATH environment variable must contain its parent directory.
  PKG_CONFIG_PATH contains the following:
      - C
      - \Users\Usuario\scoop\apps\sdl2\current\lib\pkgconfig
  HINT: you may need to install a package such as sdl2, sdl2-dev or sdl2-devel.
  stack backtrace:
     0: std::panicking::begin_panic_handler
               at /rustc/f6e511eec7342f59a25f7c0534f1dbea00d01b14\library/std\src\panicking.rs:662
     1: core::panicking::panic_fmt
               at /rustc/f6e511eec7342f59a25f7c0534f1dbea00d01b14\library/core\src\panicking.rs:74
     2: core::result::unwrap_failed
               at /rustc/f6e511eec7342f59a25f7c0534f1dbea00d01b14\library/core\src\result.rs:1677
     3: std::rt::lang_start
     4: std::rt::lang_start
     5: std::rt::lang_start
     6: std::rt::lang_start
     7: std::rt::lang_start
     8: std::rt::lang_start
     9: std::rt::lang_start
    10: std::rt::lang_start_internal::closure$2
               at /rustc/f6e511eec7342f59a25f7c0534f1dbea00d01b14\library/std\src\rt.rs:143
    11: std::panicking::try::do_call
               at /rustc/f6e511eec7342f59a25f7c0534f1dbea00d01b14\library/std\src\panicking.rs:554
    12: std::panicking::try
               at /rustc/f6e511eec7342f59a25f7c0534f1dbea00d01b14\library/std\src\panicking.rs:518
    13: std::panic::catch_unwind
               at /rustc/f6e511eec7342f59a25f7c0534f1dbea00d01b14\library/std\src\panic.rs:345
    14: std::rt::lang_start_internal
               at /rustc/f6e511eec7342f59a25f7c0534f1dbea00d01b14\library/std\src\rt.rs:143
    15: std::rt::lang_start
    16: main
    17: invoke_main
               at D:\a\_work\1\s\src\vctools\crt\vcstartup\src\startup\exe_common.inl:78
    18: __scrt_common_main_seh
               at D:\a\_work\1\s\src\vctools\crt\vcstartup\src\startup\exe_common.inl:288
    19: BaseThreadInitThunk
    20: RtlUserThreadStart
  note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

I think what is happening (I'm new to rust so my apologies if i am missing something) is that PKG_CONFIG_PATH gets divided with the ":" character (like in unix systems) instead of a semicolon ";" like in windows systems. That is why the below lines state that there are two directories in the PKG_CONFIG_PATH: "C" and "\Users\Usuario\scoop\apps\sdl2\current\lib\pkgconfig" instead of "C:\Users\Usuario\scoop\apps\sdl2\current\lib\pkgconfig".

For reference, while trying to solve this issue I had installed sd2-image (with scoop), so when both directories were in the pkg-config system path the same ":" character delimiter happened.

thread 'main' panicked at C:\Users\Usuario\.cargo\registry\src\index.crates.io-6f17d22bba15001f\sdl2-sys-0.37.0\build.rs:51:10:
  called `Result::unwrap()` on an `Err` value: 
  pkg-config exited with status code 1
  > PKG_CONFIG_PATH=C:\Users\Usuario\scoop\apps\sdl2\current\lib\pkgconfig PKG_CONFIG_ALLOW_SYSTEM_LIBS=1 PKG_CONFIG_ALLOW_SYSTEM_CFLAGS=1 pkg-config --libs --cflags sdl2
  The system library `sdl2` required by crate `sdl2-sys` was not found.
  The file `sdl2.pc` needs to be installed and the PKG_CONFIG_PATH environment variable must contain its parent directory.
  PKG_CONFIG_PATH contains the following:
      - C
      - \Users\Usuario\scoop\apps\sdl2\current\lib\pkgconfig
  HINT: you may need to install a package such as sdl2, sdl2-dev or sdl2-devel.
  stack backtrace:

Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant