PDA

View Full Version : Help me linking OpenGl using g++



yj1214
03-25-2015, 05:23 PM
#include <glew.h>


int main(){

return 0;
}


I'm trying to compile this .cpp file with g++.

this is what I did.


g++ -std=c++11 main.cpp -I/include/GL


but I'm getting an error that says "no such file: glew.h".


How do you guys compile OpenGL with g++? thanks.

Dark Photon
03-25-2015, 06:02 PM
#include <glew.h>

int main(){
return 0;
}

g++ -std=c++11 main.cpp -I/include/GL
but I'm getting an error that says "no such file: glew.h". How do you guys compile OpenGL with g++? thanks.

You're doing it right. The issue is probably that your system doesn't have the GLEW header files installed. Typically, headers are in a "*-devel" package.

For example, GLEW headers would be in a separate "glew-devel" package, where as the glew library itself is in the "glew" package. Here:



> ls /usr/include/GL/glew.h
/usr/include/GL/glew.h

> rpm -qf /usr/include/GL/glew.h
glew-devel-1.9.0-5.1.2.x86_64

yj1214
03-25-2015, 06:32 PM
I'm sorry but I don't know what -DEVEL is. In my directory, I have these.



include
lib
glew32.dll
SDL2.dll
main.cpp


My glew.h is in the include folder. So I can type g++ -I/include/GL

or do I have to do something else?

mbentrup
03-26-2015, 12:19 AM
try -I./include/GL (notice the "." before the first "/")

Dark Photon
03-26-2015, 06:55 AM
Right. Or -Iinclude/GL. You may also need to change #include <glew.h> to #include "glew.h" as well. <> means to look in the system include directories, and "" means to look in user-specified directories (basically), though the <> is up to the compiler.

Typically headers like glew.h would be installed system-wide in system include directories, so you'd use <>. But you're not doing that.