1

So basically i am compiling my program which uses GLFW

now i am successfully compiling it by using this command

gcc -o myprog glfw.c `pkg-config --static --libs glfw3`

however what i would like to know is how can i compile this simply by just using -l option

i tried the descriptions that are given by many websites and each time there was a linker DSO error and i have no idea how to fix it

and here is the latest one i tried

pkg-config --print-requires --print-requires-private glfw3 
x11
xrandr
xinerama
xi
xxf86vm
xcursor
gl

after trying with these link options

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

thats the error i get which i have no idea how to fix it

1 Answer 1

5

Nevermind i got it to work with these linker options

gcc glfw.c -lglfw3 -lGL -lm -ldl -lXinerama -lXrandr -lXi -lXcursor -lX11 -lXxf86vm -lpthread
1
  • Thanks! This worked! I knew I had to link a bunch of libraries, but I wasn't quite sure which ones. Jun 25, 2017 at 14:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.