SDL icon indicating copy to clipboard operation
SDL copied to clipboard

About disabling of SDL_X11_SHARED on Apple Platforms

Open Wohlstand opened this issue 3 years ago • 5 comments

Hello!

At some moment I found at the cmake/sdlchecks.cmake the next code:

      # !!! FIXME: why is this disabled for Apple?
      if(APPLE)
        set(SDL_X11_SHARED OFF)
      endif()

And, during my experiments on Mac OS X Tiger when I started to use X11, I found an answer to that SDL_X11_SHARED question: it just doesn't work, basically, there are no valid library paths specified, and they are always NULL, and therefore, never gets loaded. So, to allow the shared mode we need to specify library paths for the Apple platform. I think we can give the comment with a proper answer to this block.

Wohlstand avatar Dec 06 '22 23:12 Wohlstand

FindLibraryAndSONAME is not looking for the X11 libraries in any special paths.

Can you try applying the following patch:

diff --git a/cmake/sdlchecks.cmake b/cmake/sdlchecks.cmake
index 6e860415a..982089bdd 100644
--- a/cmake/sdlchecks.cmake
+++ b/cmake/sdlchecks.cmake
@@ -280,6 +280,7 @@
 macro(CheckX11)
   cmake_push_check_state()
   if(SDL_X11)
+    find_package(X11)
     foreach(_LIB X11 Xext Xcursor Xi Xfixes Xrandr Xrender Xss)
         FindLibraryAndSONAME("${_LIB}")
     endforeach()

configure CMake (with SDL_X11 enabled) and then provide me with the output of the following command:

cat CMakeCache.txt | grep "X.*_LIB"

The output will contain the result of finding the X11 libraries using the current SDL logic and CMake's FindX11 logic. If the latter works, we can probably piggyback ride it.

madebr avatar Dec 07 '22 01:12 madebr

I'll take a look today a bit later, thanks for the hint.

Wohlstand avatar Dec 07 '22 06:12 Wohlstand

Done:

whl-ppc-001-wohlnet-ru:~/Repos/SDL/build vitaly$ cat CMakeCache.txt | grep "X.*_LIB"
X11_ICE_LIB:FILEPATH=/usr/X11R6/lib/libICE.dylib
X11_LIB:FILEPATH=/usr/X11R6/lib/libX11.dylib
X11_SM_LIB:FILEPATH=/usr/X11R6/lib/libSM.dylib
X11_X11_LIB:FILEPATH=/usr/X11R6/lib/libX11.dylib
X11_XRes_LIB:FILEPATH=/usr/X11R6/lib/libXRes.dylib
X11_XTest_LIB:FILEPATH=/usr/X11R6/lib/libXtst.dylib
X11_Xau_LIB:FILEPATH=/usr/X11R6/lib/libXau.a
X11_Xcomposite_LIB:FILEPATH=X11_Xcomposite_LIB-NOTFOUND
X11_Xcursor_LIB:FILEPATH=/usr/X11R6/lib/libXcursor.dylib
X11_Xdamage_LIB:FILEPATH=X11_Xdamage_LIB-NOTFOUND
X11_Xdmcp_LIB:FILEPATH=/usr/X11R6/lib/libXdmcp.a
X11_Xext_LIB:FILEPATH=/usr/X11R6/lib/libXext.dylib
X11_Xfixes_LIB:FILEPATH=X11_Xfixes_LIB-NOTFOUND
X11_Xft_LIB:FILEPATH=/usr/X11R6/lib/libXft.dylib
X11_Xi_LIB:FILEPATH=/usr/X11R6/lib/libXi.dylib
X11_Xinerama_LIB:FILEPATH=/usr/X11R6/lib/libXinerama.dylib
X11_Xinput_LIB:FILEPATH=/usr/X11R6/lib/libXi.dylib
X11_Xkbfile_LIB:FILEPATH=/usr/X11R6/lib/libxkbfile.dylib
X11_Xmu_LIB:FILEPATH=/usr/X11R6/lib/libXmu.dylib
X11_Xpm_LIB:FILEPATH=/usr/X11R6/lib/libXpm.dylib
X11_Xrandr_LIB:FILEPATH=/usr/X11R6/lib/libXrandr.dylib
X11_Xrender_LIB:FILEPATH=/usr/X11R6/lib/libXrender.dylib
X11_Xscreensaver_LIB:FILEPATH=/usr/X11R6/lib/libXss.dylib
X11_Xt_LIB:FILEPATH=/usr/X11R6/lib/libXt.dylib
X11_Xv_LIB:FILEPATH=/usr/X11R6/lib/libXv.dylib
X11_Xxf86misc_LIB:FILEPATH=/usr/X11R6/lib/libXxf86misc.dylib
X11_Xxf86vm_LIB:FILEPATH=/usr/X11R6/lib/libXxf86vm.dylib
XCURSOR_LIB:FILEPATH=/usr/X11R6/lib/libXcursor.dylib
XEXT_LIB:FILEPATH=/usr/X11R6/lib/libXext.dylib
XFIXES_LIB:FILEPATH=XFIXES_LIB-NOTFOUND
XI_LIB:FILEPATH=/usr/X11R6/lib/libXi.dylib
XRANDR_LIB:FILEPATH=/usr/X11R6/lib/libXrandr.dylib
XRENDER_LIB:FILEPATH=/usr/X11R6/lib/libXrender.dylib
XSS_LIB:FILEPATH=/usr/X11R6/lib/libXss.dylib

Edit by madebr: removed _ADVANCED variables

Wohlstand avatar Dec 07 '22 16:12 Wohlstand

And the next output part:

-- Looking for XOpenDisplay in /usr/X11R6/lib/libX11.dylib;/usr/X11R6/lib/libXext.dylib
-- Looking for XOpenDisplay in /usr/X11R6/lib/libX11.dylib;/usr/X11R6/lib/libXext.dylib - found
-- Looking for gethostbyname
-- Looking for gethostbyname - found
-- Looking for connect
-- Looking for connect - found
-- Looking for remove
-- Looking for remove - found
-- Looking for shmat
-- Looking for shmat - found
-- Looking for IceConnectionNumber in ICE
-- Looking for IceConnectionNumber in ICE - found
-- Found X11: /usr/X11R6/lib/libX11.dylib
-- dynamic libX11 -> libX11.6.dylib
-- dynamic libXext -> libXext.6.dylib
-- dynamic libXcursor -> libXcursor.1.dylib
-- dynamic libXi -> libXi.6.dylib
-- dynamic libXrandr -> libXrandr.2.dylib
-- dynamic libXrender -> libXrender.1.dylib
-- dynamic libXss -> libXss.1.dylib

Wohlstand avatar Dec 07 '22 16:12 Wohlstand

Thanks for the logs!

So it looks like the SDL CheckX11 routines work just fine. Your include-config-<BUILD_TYPE>/build_config/SDL_build_config.h should contain e.g. #define SDL_VIDEO_DRIVER_X11_DYNAMIC "libX11.6.dylib" and contain similar values for SDL_VIDEO_DRIVER_X11_DYMAIC_XEXT, ..._XCURSOR, etc.

Perhaps your issue is about dlopen not finding these when doing dlopen, like you said in your initial post?

What happens if you add run paths to SDL3.dylib? From the command line, this can be done as follows:

cmake .. -DCMAKE_SHARED_LINKER_FLAGS="-Wl,-rpath,/usr/X11R6/lib" -DCMAKE_EXE_LINKER_FLAGS="-Wl,-rpath,/usr/X11R6/lib"

Please check manually whether -Wl,-rpath,/usr/X11R6/lib is part of the link command. And don't forget to remove the set(SDL_X11_SHARED OFF) override.

madebr avatar Dec 07 '22 19:12 madebr

SDL 2.0 is now in maintenance mode, and all inactive issues are being closed. If this issue is impacting you, please feel free to reopen it with additional information.

slouken avatar Nov 08 '23 00:11 slouken

I think, I forgot about this one, but seems doesn't matter. This issue was a kind of discussion about suspicious thing on Apple.

Wohlstand avatar Nov 08 '23 06:11 Wohlstand

I guess, to completely "fix" this issue it's enough to change the comment I mentioned into something like:

# Note: Disabled on Apple because the dynamic mode backend for X11 doesn't work properly on Apple during several issues.

Wohlstand avatar Nov 08 '23 06:11 Wohlstand

To completely solve this, the patch is needed to change the comment in CMakeLists file.

Wohlstand avatar Nov 08 '23 06:11 Wohlstand

Can you create a PR for this, just so the comment is in the right place?

slouken avatar Nov 08 '23 07:11 slouken

Ye, I'll try that very soon.

Wohlstand avatar Nov 08 '23 10:11 Wohlstand

Merged, thanks!

slouken avatar Nov 08 '23 10:11 slouken

By the way, the abandoned tag here is not suitable, and this can be changed into "closed as completed". Because all the topic was about the reason why that question was been added.

Wohlstand avatar Nov 08 '23 10:11 Wohlstand