jpbruyere / vkvg

Vulkan 2D graphics library
https://jpbruyere.github.io/vkvg/
MIT License
773 stars 33 forks source link

Fix build with static GLFW #131

Closed chrismile closed 1 year ago

chrismile commented 1 year ago

Hi,

I tried compiling vkvg on Ubuntu 20.04. glfw3 is installed via the system package manager as a static library. Unfortunately, I get the following error when building vkvg.

/usr/bin/ld: /usr/local/lib/libglfw3.a(vulkan.c.o): undefined reference to symbol 'dlclose@@GLIBC_2.2.5'

If I manually add dl to target_link_libraries, this problem is resolved, but more undefined reference errors appear (this time to GLX).

I was able to solve this problem by replacing FIND_PACKAGE(GLFW3 QUIET) by FIND_PACKAGE(glfw3 QUIET) (and adapting the GLFW3_... variables to glfw3_...). In this case, the system glfw3Config.cmake is used instead of the FindGLFW3.cmake file provided by vkvg.

The changes included in this PR solve this problem by using glfw3Config.cmake if found and FindGLFW3.cmake provided by vkvg otherwise. I believe this might also fix issue #128.