AppImageCommunity / pkg2appimage

Tool and recipes to convert existing deb packages to AppImage
http://appimage.org
MIT License
698 stars 216 forks source link

Linking against OpenGL using GLVND on Ubuntu 18.04 links wrongly against libOpenGL.so.0 #477

Open hcorion opened 3 years ago

hcorion commented 3 years ago

See the recent relevant conversation that happened over here: https://github.com/linuxdeploy/linuxdeploy/issues/152 And the relevant RPCS3-side issue here: https://github.com/RPCS3/rpcs3/issues/10226

Essentially, when building using the following:

set(OpenGL_GL_PREFERENCE GLVND)
find_package(OpenGL REQUIRED)

add_library(3rdparty_opengl INTERFACE)
target_include_directories(3rdparty_opengl INTERFACE GL)

target_link_libraries(3rdparty_opengl INTERFACE ${OPENGL_LIBRARIES})

target_compile_definitions(3rdparty_opengl
    INTERFACE
    -DGL_GLEXT_PROTOTYPES
    -DGLX_GLXEXT_PROTOTYPES)

on Ubuntu 18.04, it links against libOpenGL.so.0 directly rather than libGL, which causes issues, due to it's distro-dependence. This will cause issues because the option to GLVND use is the default configuration for newer CMake.

Tagging @TheAssassin

hcorion commented 3 years ago

The odd thing with this issue that I forgot to mention is that it it the above works fine if built on 16.04, but stops working properly in 18.04 for some reason.

JulianGro commented 2 years ago

I don't see how linking to libOpenGL.so.0 is wrong. You are supposed to link to libOpenGL which in turn will act as a wrapper for libGLdispatch. Legacy behaviour would be to link libGL which will also act as a wrapper on modern systems. My understanding is that it only provides GLX compatibility and no EGL compatibility like libOpenGL does, though that might not be accurate. Whatever the case, I am sure there is a reason for libGL being "provided for backwards-compatibility" only. (See their documentation https://github.com/NVIDIA/libglvnd)

By the way, the point of glvnd is that multiple graphics drivers can coexist on the same system. Before glvnd, an Nvidia proprietary driver for example had to provide its own libGL and libOpenGL. Then if you had another driver vendor like Mesa on the same system you ran into the conflict that they too had to provide these libraries, but Nvidias libaries were already present.