How to prevent GLFW from trying to link vulkan functions?


Hi, I encountered the following errors when I tried to compile an OpenGL program using GLFW:

g++     -o dist/Debug/GNU-Linux/opengl1 build/Debug/GNU-Linux/01-triangles.o -L/home/me/glfw-3.2.1/bin/lib -lglfw3 -pthread -lGLU -lGL -lrt -lXrandr -lXxf86vm -lXi -lXinerama -lX11
/usr/bin/ld: /home/me/glfw-3.2.1/bin/lib/libglfw3.a(vulkan.c.o): undefined reference to symbol 'dlclose@@GLIBC_2.2.5'
//lib/x86_64-linux-gnu/ error adding symbols: DSO missing from command line

It seems that dlclose is a vulkan function which GLFW tries to link but vulkan is not installed on the Linux system I am using. So how to prevent GLFW from trying to link any vulkan function, or have GLFW library not include any vulkan entries when I build it from GLFW source, or is there any other way that can make me successfully compile the program on linux? Thank a lot.


dlclose is not a Vulkan function. It is dynamic linker library function. You need to link to dl library. Try adding -ldl to linker arguments.


Thank you for the reply. I had thought the problem is related to vulkan so I asked in particular in this separate thread, but after I added -ldl, the linker errors returns to its origin. Could you please take a look at the problem in thread “How to link GLFW?” Thanks a lot.