所以基本上我正在编译我的程序,它使用 GLFW
现在我使用这个命令成功编译了它
gcc -o myprog glfw.c `pkg-config --static --libs glfw3`
但是我想知道的是我怎样才能通过使用 -l 选项简单地编译它
我尝试了很多网站给出的描述,每次都出现链接器 DSO 错误,我不知道如何修复它
这是我最近试过的一个
pkg-config --print-requires --print-requires-private glfw3
x11
xrandr
xinerama
xi
xxf86vm
xcursor
gl
尝试使用这些链接选项后
gcc -o myprog glfw.c -lglfw3 -lX11 -lXrandr -lXinerama -lXi -lXxf86vm -lXcursor -lGL
/usr/bin/ld: //usr/local/lib/libglfw3.a(glx_context.c.o): undefined reference to symbol 'dlclose@@GLIBC_2.2.5'
//lib/x86_64-linux-gnu/libdl.so.2: error adding symbols: DSO missing from command line
collect2: error: ld returned 1 exit status
这就是我得到的错误,我不知道如何修复它
最佳答案
没关系,我让它与这些链接器选项一起工作
gcc glfw.c -lglfw3 -lGL -lm -ldl -lXinerama -lXrandr -lXi -lXcursor -lX11 -lXxf86vm -lpthread
关于c++ - 使用链接 linux 编译 GLFW 应用程序问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34340462/