I am currently developing a little program, and faced an issue when I tried to run it on a clean Linux distribution: OpenGL freeglut3 was not installed by default. I faced the same issue when I compiled it for windows.
To circumvent this issue, I looked to static linking the libraries, kind-of embedding them into the executable. The full command I used is g++ thing.cpp -Wall -o thing -static -lGL -lglut -static-libgcc -static-libstdc++.
little edit: compiling it without -static just works, but only statically includes libgcc and libstdc++
The error message I got is:
coolperson@iogamesplayer:~/c++/text/program$ g++ thing.cpp -o thing -static -lGL -lglut -static-libgcc -static-libstdc++
/usr/bin/ld: cannot find -lGL: No such file or directory
collect2: error: ld returned 1 exit status
coolperson@iogamesplayer:~/c++/thing/program$
I can compile it normally, and I have statically linked the default libraries by using g++ thing.cpp -o thing -static-libgcc -static-libstdc++.
What I tried is using my own compiled freeglut 3.4.0, that didn't work. I couldn't find anything online.
I tried asking Reddit, but reddit being reddit didn't exactly tell me what I was doing wrong, and how to statically link it :P.
Tell me what I'm doing wrong, and how I can statically link openGL glut.h.
-lflag). I'm not sure if glut can interopate with GLEW though... Honestly I would forget about GLUT, it is old and unmaintained.glewInit()afterglutCreateWindow().