0

I am trying to create a static library for my engine. The command (in a makefile) is:

g++ -c -fPIC window.cc -lGL -lGLEW -lSDL2 -std=c++14 -I../include/ && g++ -static window.o -lSDL2 -lGL -lGLEW -o ../distribute/so/window.so

So, the first command compiles successful, but the other one outputs this:

/usr/bin/ld: cannot find -lGL
/usr/bin/ld: cannot find -lGLEW
collect2: error: ld returned 1 exit status

But I definitely need those arguments. Can we fix it?

1 Answers1

0

You need to know the exact paths of the library files to be linked with. The directories that contain them should be added to your link line with -L.

MrJLP
  • 978
  • 6
  • 14
  • Thank you, but that doesnt work for me, also, wouldn`t it be OS dependent then? –  Apr 26 '17 at 18:21
  • When I link with -L /usr/lib/libGL.so -L /usr/lib/x86_64-linux-gnu/libGLEW.so, the shared objects are found, but I keep getting errors about g++ not finding the library functions –  Apr 26 '17 at 18:26
  • You're statically linking it though so it won't use `.so`. It will use `.a` libraries. You need to show the exact error if you want people to help you debug things. – MrJLP Apr 26 '17 at 18:28
  • And you put directories after `-L`, not the file – MrJLP Apr 26 '17 at 18:31
  • you probably need to install the '-dev' version of those packages to get the static libs – MrJLP Apr 26 '17 at 18:32
  • Ok, sorry, it finaly worked. That -static wasn`t supposed to be there, I guess -_- Anyway, thanks for answering! –  Apr 26 '17 at 18:34