Sign in to follow this  
Mariusz Pilipczuk

OpenGL OpenGL shaders in Windows

Recommended Posts

Hello,

 

I was recently trying to compile my game engine on Windows, but I ran into a serious problem. I am using SDL and OpenGL, and I link with the following options:

 

-lmingw32 -lSDLmain -lSDL -lopengl32 -lglu32
 

I use the Code::Blocks IDE. When I compile the engine, I get the following errors:

 

obj\Debug\specfx\specfx.o||In function `meCreateEffect':|
C:\Age of Prisoners stuff\Madd Engine (ME)\me-1.0.0\specfx\specfx.c|61|undefined reference to `glCreateProgram@0'|
obj\Debug\specfx\specfx.o||In function `meAttachShaderFromMemory':|
C:\Age of Prisoners stuff\Madd Engine (ME)\me-1.0.0\specfx\specfx.c|97|undefined reference to `glCreateShader@4'|
C:\Age of Prisoners stuff\Madd Engine (ME)\me-1.0.0\specfx\specfx.c|98|undefined reference to `glCreateShader@4'|
C:\Age of Prisoners stuff\Madd Engine (ME)\me-1.0.0\specfx\specfx.c|99|undefined reference to `glShaderSource@16'|
C:\Age of Prisoners stuff\Madd Engine (ME)\me-1.0.0\specfx\specfx.c|100|undefined reference to `glCompileShader@4'|
C:\Age of Prisoners stuff\Madd Engine (ME)\me-1.0.0\specfx\specfx.c|102|undefined reference to `glGetShaderiv@12'|
C:\Age of Prisoners stuff\Madd Engine (ME)\me-1.0.0\specfx\specfx.c|106|undefined reference to `glGetShaderiv@12'|
C:\Age of Prisoners stuff\Madd Engine (ME)\me-1.0.0\specfx\specfx.c|108|undefined reference to `glGetShaderInfoLog@16'|
C:\Age of Prisoners stuff\Madd Engine (ME)\me-1.0.0\specfx\specfx.c|122|undefined reference to `glAttachShader@8'|
C:\Age of Prisoners stuff\Madd Engine (ME)\me-1.0.0\specfx\specfx.c|138|undefined reference to `glCreateShader@4'|
C:\Age of Prisoners stuff\Madd Engine (ME)\me-1.0.0\specfx\specfx.c|140|undefined reference to `glShaderSource@16'|
C:\Age of Prisoners stuff\Madd Engine (ME)\me-1.0.0\specfx\specfx.c|141|undefined reference to `glCompileShader@4'|
C:\Age of Prisoners stuff\Madd Engine (ME)\me-1.0.0\specfx\specfx.c|143|undefined reference to `glGetShaderiv@12'|
C:\Age of Prisoners stuff\Madd Engine (ME)\me-1.0.0\specfx\specfx.c|147|undefined reference to `glGetShaderiv@12'|
C:\Age of Prisoners stuff\Madd Engine (ME)\me-1.0.0\specfx\specfx.c|149|undefined reference to `glGetShaderInfoLog@16'|
C:\Age of Prisoners stuff\Madd Engine (ME)\me-1.0.0\specfx\specfx.c|162|undefined reference to `glAttachShader@8'|
C:\Age of Prisoners stuff\Madd Engine (ME)\me-1.0.0\specfx\specfx.c|172|undefined reference to `glCreateShader@4'|
C:\Age of Prisoners stuff\Madd Engine (ME)\me-1.0.0\specfx\specfx.c|174|undefined reference to `glShaderSource@16'|
C:\Age of Prisoners stuff\Madd Engine (ME)\me-1.0.0\specfx\specfx.c|175|undefined reference to `glCompileShader@4'|
C:\Age of Prisoners stuff\Madd Engine (ME)\me-1.0.0\specfx\specfx.c|177|undefined reference to `glGetShaderiv@12'|
C:\Age of Prisoners stuff\Madd Engine (ME)\me-1.0.0\specfx\specfx.c|181|undefined reference to `glGetShaderiv@12'|
C:\Age of Prisoners stuff\Madd Engine (ME)\me-1.0.0\specfx\specfx.c|183|undefined reference to `glGetShaderInfoLog@16'|
C:\Age of Prisoners stuff\Madd Engine (ME)\me-1.0.0\specfx\specfx.c|196|undefined reference to `glAttachShader@8'|
obj\Debug\specfx\specfx.o||In function `meLinkShaders':|
C:\Age of Prisoners stuff\Madd Engine (ME)\me-1.0.0\specfx\specfx.c|210|undefined reference to `glLinkProgram@4'|
C:\Age of Prisoners stuff\Madd Engine (ME)\me-1.0.0\specfx\specfx.c|212|undefined reference to `glGetProgramiv@12'|
obj\Debug\specfx\specfx.o||In function `meApplyEffect':|
C:\Age of Prisoners stuff\Madd Engine (ME)\me-1.0.0\specfx\specfx.c|228|undefined reference to `glUseProgram@4'|
obj\Debug\specfx\specfx.o||In function `meDeleteEffect':|
C:\Age of Prisoners stuff\Madd Engine (ME)\me-1.0.0\specfx\specfx.c|266|undefined reference to `glDeleteProgram@4'|
obj\Debug\video\shader.o||In function `me_init_shader':|
C:\Age of Prisoners stuff\Madd Engine (ME)\me-1.0.0\video\shader.c|69|undefined reference to `glCreateShader@4'|
C:\Age of Prisoners stuff\Madd Engine (ME)\me-1.0.0\video\shader.c|70|undefined reference to `glShaderSource@16'|
C:\Age of Prisoners stuff\Madd Engine (ME)\me-1.0.0\video\shader.c|71|undefined reference to `glCompileShader@4'|
C:\Age of Prisoners stuff\Madd Engine (ME)\me-1.0.0\video\shader.c|73|undefined reference to `glCreateShader@4'|
C:\Age of Prisoners stuff\Madd Engine (ME)\me-1.0.0\video\shader.c|74|undefined reference to `glShaderSource@16'|
C:\Age of Prisoners stuff\Madd Engine (ME)\me-1.0.0\video\shader.c|75|undefined reference to `glCompileShader@4'|
C:\Age of Prisoners stuff\Madd Engine (ME)\me-1.0.0\video\shader.c|77|undefined reference to `glCreateProgram@0'|
C:\Age of Prisoners stuff\Madd Engine (ME)\me-1.0.0\video\shader.c|78|undefined reference to `glAttachShader@8'|
C:\Age of Prisoners stuff\Madd Engine (ME)\me-1.0.0\video\shader.c|79|undefined reference to `glAttachShader@8'|
C:\Age of Prisoners stuff\Madd Engine (ME)\me-1.0.0\video\shader.c|80|undefined reference to `glLinkProgram@4'|
C:\Age of Prisoners stuff\Madd Engine (ME)\me-1.0.0\video\shader.c|81|undefined reference to `glUseProgram@4'|
obj\Debug\video\shader.o||In function `meSaveShaderInfoLog':|
C:\Age of Prisoners stuff\Madd Engine (ME)\me-1.0.0\video\shader.c|101|undefined reference to `glGetProgramiv@12'|
C:\Age of Prisoners stuff\Madd Engine (ME)\me-1.0.0\video\shader.c|105|undefined reference to `glGetProgramInfoLog@16'|
obj\Debug\video\shader.o||In function `me_shader_variablei':|
C:\Age of Prisoners stuff\Madd Engine (ME)\me-1.0.0\video\shader.c|126|undefined reference to `glGetUniformLocation@8'|
C:\Age of Prisoners stuff\Madd Engine (ME)\me-1.0.0\video\shader.c|127|undefined reference to `glUniform1i@8'|
obj\Debug\video\shader.o||In function `me_shader_variabled':|
C:\Age of Prisoners stuff\Madd Engine (ME)\me-1.0.0\video\shader.c|140|undefined reference to `glGetUniformLocation@8'|
C:\Age of Prisoners stuff\Madd Engine (ME)\me-1.0.0\video\shader.c|141|undefined reference to `glUniform1d'|
obj\Debug\video\shader.o||In function `me_shader_variablef':|
C:\Age of Prisoners stuff\Madd Engine (ME)\me-1.0.0\video\shader.c|154|undefined reference to `glGetUniformLocation@8'|
C:\Age of Prisoners stuff\Madd Engine (ME)\me-1.0.0\video\shader.c|155|undefined reference to `glUniform1f@8'|
||=== Build finished: 46 errors, 0 warnings ===|

Which looks like the shader API is not there :(.

 

Has anyone ran into this problem? Do you know how to solve it?

 

All help is appreciated.

Share this post


Link to post
Share on other sites

But this appears to be a linker error. Am I supposed to link with another library? If so, what library is it? Also, I believe SDL loads the functions for me, and even if it didn't, it wouldn't be a LINKER error, just a runtime error.

Share this post


Link to post
Share on other sites
Geometrian    1810

If you're using GL 2 headers, which you most likely are, you need to load shaders, fbos, etc. as extensions.

It is recommended to do this with a library. GLEW and GLEE are the two major ones.

-G

Share this post


Link to post
Share on other sites
Daaark    3553
Is it still OK if I use SDL though? Because SDL does all the initialising for me, and on Linux it was enough to get the shaders working. And if it's possible, can anyone give na example?
It doesn't work the same on Linux.

The OpenGL library that ships with Windows is OpenGL 1.1. All the newer functionality is provided by the driver for your GPU and supplied by the IHV. So you need to supply yourself with a newer version of GL.H, and manually create function pointers to anything newer than 1.1. That's what GLEW or GLEE are for.

Share this post


Link to post
Share on other sites
kop0113    2453
Does -lglu32 not need to go before -lopengl32?

I remember running into something like this but it might have been with glut.

Also try linking -lglew32 (before -lopengl32 and -lglu32). Glew can be a little tricky to compile up in mingw, but it is possible. Edited by Karsten_

Share this post


Link to post
Share on other sites
wizardpc    282

I just went though the same thing.  I was developing my game on Mac, and then after 1 year of getting the game in a good alpha state, I decieded to take that fearful leap and attempt to get it compiled on WIndows. (probably not the best idea to wait a year).

 

That's when I found out that I had to use glew because windows only had OpenGL 1.1 as mentioned aboved.  Download the glew library, link to it, and I believe there is one init you have to do

 

glewinit()

 

I was using GLFW to create my window, and not SDL, but I'm sure this advice works for you too.  I read that you have to call "glewinit()" after you create your window.  So I had to make sure I called glewinit() after my glfwinit() function that set up the window.

 

Hopefully that helps you out.  After getting GLEW in the project and calling the init, my linker errors were resolved.  Hopefully this helps you some.

Edited by wizardpc

Share this post


Link to post
Share on other sites
mhagain    13430

is GLEW built-in on Windows, or do I need to get some kind of DLL and headers from somewhere?


You need to get it yourself.

You can #define GLEW_STATIC before including glew32.h and GLEW will statically link with your program - probably a good option if you can't rely on your end-users having it (you need to link to glew32s.lib rather than glew32.lib if you do this). Edited by mhagain

Share this post


Link to post
Share on other sites

OK, now I have 2 problems.

 

If I include glew (the include file is called GL/glew.h) then it makes lots of re-declarations of symbols from SDL and vice-versa. If I don't include it, then there is no compilations error, but there is still a linker error, with all of the undefined references I showed above, as well as an undefined reference to glewInit() -.-

 

I'm passing the -lglew32 flag to the linker. Does anyone know why this is happening?

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this  

  • Similar Content

    • By povilaslt2
      Hello. I'm Programmer who is in search of 2D game project who preferably uses OpenGL and C++. You can see my projects in GitHub. Project genre doesn't matter (except MMO's :D).
    • By ZeldaFan555
      Hello, My name is Matt. I am a programmer. I mostly use Java, but can use C++ and various other languages. I'm looking for someone to partner up with for random projects, preferably using OpenGL, though I'd be open to just about anything. If you're interested you can contact me on Skype or on here, thank you!
      Skype: Mangodoor408
    • By tyhender
      Hello, my name is Mark. I'm hobby programmer. 
      So recently,I thought that it's good idea to find people to create a full 3D engine. I'm looking for people experienced in scripting 3D shaders and implementing physics into engine(game)(we are going to use the React physics engine). 
      And,ye,no money =D I'm just looking for hobbyists that will be proud of their work. If engine(or game) will have financial succes,well,then maybe =D
      Sorry for late replies.
      I mostly give more information when people PM me,but this post is REALLY short,even for me =D
      So here's few more points:
      Engine will use openGL and SDL for graphics. It will use React3D physics library for physics simulation. Engine(most probably,atleast for the first part) won't have graphical fron-end,it will be a framework . I think final engine should be enough to set up an FPS in a couple of minutes. A bit about my self:
      I've been programming for 7 years total. I learned very slowly it as "secondary interesting thing" for like 3 years, but then began to script more seriously.  My primary language is C++,which we are going to use for the engine. Yes,I did 3D graphics with physics simulation before. No, my portfolio isn't very impressive. I'm working on that No,I wasn't employed officially. If anybody need to know more PM me. 
       
    • By Zaphyk
      I am developing my engine using the OpenGL 3.3 compatibility profile. It runs as expected on my NVIDIA card and on my Intel Card however when I tried it on an AMD setup it ran 3 times worse than on the other setups. Could this be a AMD driver thing or is this probably a problem with my OGL code? Could a different code standard create such bad performance?
    • By Kjell Andersson
      I'm trying to get some legacy OpenGL code to run with a shader pipeline,
      The legacy code uses glVertexPointer(), glColorPointer(), glNormalPointer() and glTexCoordPointer() to supply the vertex information.
      I know that it should be using setVertexAttribPointer() etc to clearly define the layout but that is not an option right now since the legacy code can't be modified to that extent.
      I've got a version 330 vertex shader to somewhat work:
      #version 330 uniform mat4 osg_ModelViewProjectionMatrix; uniform mat4 osg_ModelViewMatrix; layout(location = 0) in vec4 Vertex; layout(location = 2) in vec4 Normal; // Velocity layout(location = 3) in vec3 TexCoord; // TODO: is this the right layout location? out VertexData { vec4 color; vec3 velocity; float size; } VertexOut; void main(void) { vec4 p0 = Vertex; vec4 p1 = Vertex + vec4(Normal.x, Normal.y, Normal.z, 0.0f); vec3 velocity = (osg_ModelViewProjectionMatrix * p1 - osg_ModelViewProjectionMatrix * p0).xyz; VertexOut.velocity = velocity; VertexOut.size = TexCoord.y; gl_Position = osg_ModelViewMatrix * Vertex; } What works is the Vertex and Normal information that the legacy C++ OpenGL code seem to provide in layout location 0 and 2. This is fine.
      What I'm not getting to work is the TexCoord information that is supplied by a glTexCoordPointer() call in C++.
      Question:
      What layout location is the old standard pipeline using for glTexCoordPointer()? Or is this undefined?
       
      Side note: I'm trying to get an OpenSceneGraph 3.4.0 particle system to use custom vertex, geometry and fragment shaders for rendering the particles.
  • Popular Now