I'm trying to create a static shader library with OpenGL. I want it to be as portable as possible (Windows Linus Android ...). For this propose i made a header what includes gl and glext: OpenGL.hpp
...
#define GL_GLEXT_PROTOTYPES
#if defined(OS_WINDOWS)
#ifdef _MSC_VER
#include <windows.h>
#endif
#include <GL/gl.h>
#include <GL/glext.h>
#elif defined(OS_LINUX)
#include <GL/gl.h>
#include <GL/glext.h>
...
And Shader.hpp
...
class Shader
{
unsigned int m_id;
public:
Shader();
...
};
...
And Shader.cpp
...
#include <Shader.hpp>
#include <OpenGL.hpp>
Shader::Shader()
{
m_id = glCreateProgram();
...
}
...
Then complied Shader.cpp
to Shader.o
and with ar
created libShader.a
.
After that on android i can compile like that:
g++ -I ./include -c main.cpp -o main.o
g++ -L ./lib -o main main.o -lShader -lSDL2 -lGLESv1_CM -lGLESv2
And it runs flawless. But on windows when i link
g++ -L ./lib -o main.exe main.o -lShader -lSDL2 -lglew32 -lopengl32 -lglu32
G++ gives lib\libShader.a(Shader.o):Shader.cpp undefined reference to glCreateProgram@8
error.
On windows main.cpp looks like this:
#include <GL/glew.h>
#include <Shader.hpp>
...
int main()
{
Shader shader1;
...
GLuint test_id_for_main = glCreateProgram();
...
}
...
The wierd thing is test_id_for_main
works (if i comment out the Shader-s) without link error.
What did i do incorrectly on windows?