Skip to content

[sdl2] Fix pkgconfig: missing system libs#13551

Closed
gdxn96 wants to merge 2 commits intomicrosoft:masterfrom
gdxn96:patch-1
Closed

[sdl2] Fix pkgconfig: missing system libs#13551
gdxn96 wants to merge 2 commits intomicrosoft:masterfrom
gdxn96:patch-1

Conversation

@gdxn96
Copy link

@gdxn96 gdxn96 commented Sep 15, 2020

CMake Error at scripts/cmake/vcpkg_fixup_pkgconfig.cmake:232 (message):
  Library "glib-2.0" was not found! If it is a system library use the
  SYSTEM_LIBRARIES parameter for the vcpkg_fixup_pkgconfig call! Otherwise,
  correct the *.pc file
Call Stack (most recent call first):
  scripts/cmake/vcpkg_fixup_pkgconfig.cmake:298 (vcpkg_fixup_pkgconfig_check_files)
  ports/sdl2/portfile.cmake:97 (vcpkg_fixup_pkgconfig)
  scripts/ports.cmake:79 (include)

@ghost
Copy link

ghost commented Sep 15, 2020

CLA assistant check
All CLA requirements met.

@gdxn96 gdxn96 marked this pull request as ready for review September 15, 2020 21:15
@ras0219
Copy link
Contributor

ras0219 commented Sep 16, 2020

Hi @gdxn96, thanks for the PR!

Could you try the branch in #13126 and see if that solves your issue? If not, could you please post the contents of the .pc files here?

Because glib is packaged inside vcpkg, we don't want to directly link the system glib accidentally.

@JackBoosY JackBoosY self-assigned this Sep 16, 2020
@JackBoosY JackBoosY added requires:author-response category:port-bug The issue is with a library, which is something the port should already support labels Sep 16, 2020
@gdxn96
Copy link
Author

gdxn96 commented Sep 16, 2020

@ras0219 @JackBoosY unfortunately that branch did not fix the glib issue

-- Building x64-linux-rel
-- Fixing pkgconfig file: /home/george/Desktop/git/vcpkg/packages/sdl2_x64-linux/lib/pkgconfig/sdl2.pc
CMake Error at scripts/cmake/vcpkg_fixup_pkgconfig.cmake:136 (message):
  find_library() failed with result: CHECK_LIB_glib-2.0_RELEASE-NOTFOUND

      find_library(CHECK_LIB_glib-2.0_RELEASE NAMES "glib-2.0" PATHS /home/george/Desktop/git/vcpkg/packages/sdl2_x64-linux/lib/pkgconfig/../../lib "/home/george/Desktop/git/vcpkg/installed/x64-linux/lib" NO_DEFAULT_PATH)
Call Stack (most recent call first):
  scripts/cmake/vcpkg_fixup_pkgconfig.cmake:234 (vcpkg_fixup_pkgconfig_check_files)
  ports/sdl2/portfile.cmake:97 (vcpkg_fixup_pkgconfig)
  scripts/ports.cmake:79 (include)


Error: Building package sdl2:x64-linux failed with: BUILD_FAILED
Please ensure you're using the latest portfiles with `./vcpkg update`, then
submit an issue at https://github.com/Microsoft/vcpkg/issues including:
  Package: sdl2:x64-linux
  Vcpkg version: 2020.06.15-unknownhash

sdl2.pc file

prefix=${pcfiledir}/../..
# sdl pkg-config source file

exec_prefix=${prefix}
libdir=${exec_prefix}/lib
includedir=${prefix}/include

Name: sdl2
Description: 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.
Version: 2.0.12
Requires:
Conflicts:
Libs: -L"${libdir}" -Wl,-rpath,${libdir} -Wl,--enable-new-dtags -pthread -lSDL2  -lglib-2.0 -lgobject-2.0 -lgio-2.0 -libus-1.0 -ldbus-1 -l/usr/lib/x86_64-linux-gnu/libsndio.so -ldl -lm  -Wl,--no-undefined -pthread -lSDL2 
Cflags: -I"${includedir}/SDL2"  -D_REENTRANT

vcpkg_fixup_pkgconfig(
IGNORE_FLAGS "-Wl,-rpath,${CURRENT_PACKAGES_DIR}/lib/pkgconfig/../../lib" "-Wl,-rpath,${CURRENT_PACKAGES_DIR}/debug/lib/pkgconfig/../../lib" "-Wl,--enable-new-dtags" "-Wl,--no-undefined" "-Wl,-undefined,error" "-Wl,-compatibility_version,${DYLIB_COMPATIBILITY_VERSION}" "-Wl,-current_version,${DYLIB_CURRENT_VERSION}" "-Wl,-weak_framework,Metal" "-Wl,-weak_framework,QuartzCore"
SYSTEM_LIBRARIES dbus-1
SYSTEM_LIBRARIES dbus-1 glib-2.0 gobject-2.0 gio-2.0 ibus-1.0
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't know why sdl2 need them.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All I know, is SDL2 failed to install locally without this change. Once I added this change it worked fine.

I don't understand Cmake very well so if this change is not appropriate just lmk.

Maybe it's an OS thing? I'm using Ubuntu 20.04, maybe they were previously installed by default and no longer are? (grasping straws)

@JackBoosY
Copy link
Contributor

@gdxn96 Could you provide your broken sdl2.pc?

@gdxn96
Copy link
Author

gdxn96 commented Sep 17, 2020

The one I have above? @JackBoosY
If not that one then I'll reset to master and reinstall later tonight to generate another

@gdxn96
Copy link
Author

gdxn96 commented Sep 17, 2020

@JackBoosY
broken sdl2.pc

prefix=${pcfiledir}/../..
# sdl pkg-config source file

exec_prefix=${prefix}
libdir=${exec_prefix}/lib
includedir=${prefix}/include

Name: sdl2
Description: 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.
Version: 2.0.12
Requires:
Conflicts:
Libs: -L${libdir} -Wl,-rpath,${libdir} -Wl,--enable-new-dtags -pthread -lSDL2 
Libs.private: -lglib-2.0 -lgobject-2.0 -lgio-2.0 -libus-1.0 -ldbus-1 -l/usr/lib/x86_64-linux-gnu/libsndio.so -ldl -lm  -Wl,--no-undefined -pthread -lSDL2 
Cflags: -I${includedir}/SDL2  -D_REENTRANT

@ras0219-msft
Copy link
Contributor

I think that this is indicative that we can't expect to list out the full set of system dependencies; it would require us to somehow divine the precise naming and linkage structure of every system out there.

For now, this is blocked on #13126

@jube
Copy link
Contributor

jube commented Oct 12, 2020

If you install glib from vcpkg, you only have to set ibus-1.0 as a system dependency. So, the patch should be changed to depend on glib and add ibus as a system dependency.

@jube jube mentioned this pull request Oct 12, 2020
@marcel-ibay
Copy link

If you install glib from vcpkg, you only have to set ibus-1.0 as a system dependency. So, the patch should be changed to depend on glib and add ibus as a system dependency.

Was there a documentation on how this could be achieved? It seems more safer than deleting ibus from the host environment.
When I added sdl2 as part of dependencies in vcpkg.json, vcpkg automatically searches for sdl2's dependencies within its ports. How can we add a specific library that are present in the host environment to be used by vcpkg when searching for dependencies?

@jgilje
Copy link
Contributor

jgilje commented Oct 23, 2020

Just wanted to add to the discussion as I mistakenly opened an identical PR in #14019

The root issue is that the SDL2 CMakeLists.txt detects that an ibus-1.0 development package is available and uses pkg-config to add fetch linker flags for ibus. The resulting dependencies can be seen by manually running pkg-config on a machine with this package installed (libibus-1.0-dev on an Debian/Ubuntu distro):

$ pkg-config --libs ibus-1.0
-libus-1.0 -lgio-2.0 -lgobject-2.0 -lglib-2.0

The search for Ibus is scoped to only apply to Linux systems. Personally, I'd recommend adding a patch which simply removes the ibus detection lines from SDL2's CMakeLists, and the entire issue at talk here could be closed.

@jgilje
Copy link
Contributor

jgilje commented Oct 28, 2020

@jube or @JackBoosY: Seeing there appears to be no further progress here, and I'm keen to get this solved, is it OK for me to open a new PR based on my suggested fix?

@JackBoosY
Copy link
Contributor

@jgilje Sure, please!

@gdxn96
Copy link
Author

gdxn96 commented Oct 28, 2020

@jube or @JackBoosY: Seeing there appears to be no further progress here, and I'm keen to get this solved, is it OK for me to open a new PR based on my suggested fix?

If you know what you're doing, please go for it, lord knows I don't 😁

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

category:port-bug The issue is with a library, which is something the port should already support

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[sdl2[core]:x64-linux] build failure

7 participants