\$30

### Image of the Day Submit

IOTD | Top Screenshots

### The latest, straight to your Inbox.

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.

16 replies to this topic

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'|
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|99|undefined reference to glShaderSource@16'|
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|108|undefined reference to glGetShaderInfoLog@16'|
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|141|undefined reference to glCompileShader@4'|
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|162|undefined reference to glAttachShader@8'|
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|177|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'|
obj\Debug\specfx\specfx.o||In function meLinkShaders':|
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'|
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|71|undefined reference to glCompileShader@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|77|undefined reference to glCreateProgram@0'|
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|81|undefined reference to glUseProgram@4'|
C:\Age of Prisoners stuff\Madd Engine (ME)\me-1.0.0\video\shader.c|101|undefined reference to glGetProgramiv@12'|
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|127|undefined reference to glUniform1i@8'|
C:\Age of Prisoners stuff\Madd Engine (ME)\me-1.0.0\video\shader.c|140|undefined reference to glGetUniformLocation@8'|
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|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.

### #2mhagain  Members

Posted 14 January 2013 - 11:58 AM

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.

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.

### #4Geometrian  Members

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.

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?

### #6Brother Bob  Moderators

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.

### #7MrDaaark  Members

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.

### #8Karsten_  Members

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.

http://tinyurl.com/shewonyay - Thanks so much for those who voted on my GF's Competition Cosplay Entry for Cosplayzine. She won! I owe you all beers

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

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?

### #10wintertime  Members

Posted 15 January 2013 - 10:11 AM

You need to get it yourself.

### #11wizardpc  Members

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.

### #12mhagain  Members

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.

### #13larspensjo  Members

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/

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?

Posted 20 January 2013 - 01:55 PM

?

### #16wintertime  Members

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