Jump to content

  • Log In with Google      Sign In   
  • Create Account

OpenGL shaders in Windows


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
16 replies to this topic

#1 Madd   Members   -  Reputation: 168

Like
0Likes
Like

Posted 14 January 2013 - 11:31 AM

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.



Sponsor:

#2 mhagain   Crossbones+   -  Reputation: 7978

Like
0Likes
Like

Posted 14 January 2013 - 11:58 AM

Have a read here: http://www.opengl.org/wiki/Getting_Started#Getting_Functions


It appears that the gentleman thought C++ was extremely difficult and he was overjoyed that the machine was absorbing it; he understood that good C++ is difficult but the best C++ is well-nigh unintelligible.


#3 Madd   Members   -  Reputation: 168

Like
0Likes
Like

Posted 14 January 2013 - 01:14 PM

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.



#4 Geometrian   Crossbones+   -  Reputation: 1544

Like
3Likes
Like

Posted 14 January 2013 - 01:20 PM

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


And a Unix user said rm -rf *.* and all was null and void...|There's no place like 127.0.0.1|The Application "Programmer" has unexpectedly quit. An error of type A.M. has occurred.

#5 Madd   Members   -  Reputation: 168

Like
0Likes
Like

Posted 14 January 2013 - 01:32 PM

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?



#6 Brother Bob   Moderators   -  Reputation: 8197

Like
2Likes
Like

Posted 14 January 2013 - 02:15 PM

Of course you can still use SDL. The two libraries mentioned above do not compete with SDL and can perfectly well be used together.



#7 MrDaaark   Members   -  Reputation: 3555

Like
0Likes
Like

Posted 14 January 2013 - 02:44 PM

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.

#8 Karsten_   Members   -  Reputation: 1604

Like
0Likes
Like

Posted 15 January 2013 - 05:44 AM

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_, 15 January 2013 - 05:45 AM.

Mutiny - Open-source C++ Unity re-implementation.
Defile of Eden 2 - FreeBSD and OpenBSD binaries of our latest game.


#9 Madd   Members   -  Reputation: 168

Like
0Likes
Like

Posted 15 January 2013 - 10:08 AM

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



#10 wintertime   Members   -  Reputation: 1714

Like
0Likes
Like

Posted 15 January 2013 - 10:11 AM

You need to get it yourself.



#11 wizardpc   Members   -  Reputation: 282

Like
2Likes
Like

Posted 15 January 2013 - 05:44 PM

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, 15 January 2013 - 05:45 PM.


#12 mhagain   Crossbones+   -  Reputation: 7978

Like
1Likes
Like

Posted 16 January 2013 - 04:54 AM


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, 16 January 2013 - 09:05 PM.

It appears that the gentleman thought C++ was extremely difficult and he was overjoyed that the machine was absorbing it; he understood that good C++ is difficult but the best C++ is well-nigh unintelligible.


#13 larspensjo   Members   -  Reputation: 1540

Like
0Likes
Like

Posted 18 January 2013 - 08:03 AM

You can use GLEW the same way in Linux (or wherever) also, which means you don't have to make things two different ways.


Current project: Ephenation.
Sharing OpenGL experiences: http://ephenationopengl.blogspot.com/

#14 Madd   Members   -  Reputation: 168

Like
0Likes
Like

Posted 20 January 2013 - 09:05 AM

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?



#15 Madd   Members   -  Reputation: 168

Like
0Likes
Like

Posted 20 January 2013 - 01:55 PM

?



#16 wintertime   Members   -  Reputation: 1714

Like
0Likes
Like

Posted 20 January 2013 - 02:10 PM

- dont include gl.h as glew.h takes care of this

- include glew.h in the files when you are using opengl functions

- try if including glew.h or sdl headers should be first



#17 Madd   Members   -  Reputation: 168

Like
0Likes
Like

Posted 20 January 2013 - 02:24 PM

The thing is, i'm not including gl.h, I'm including SDL_opengl.h. This is confusing. Plus this would not cause linker errors. Isn't there anything else I need to link with? There were 4 different libs with GLEW.






Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS