What do I link with to get glslang?

Hi people. I’ve finally gotten around to start writing some glslang code. I think my code compiles correctly but I get linker errors. My makefile looks like this:

glslang: main.cpp
    g++ -o glslang main.cpp -lglut

I get errors like:

g++ -o glslang main.cpp -lglut
/tmp/ccXPf0aL.o(.text+0x19b): In function `InitGL()':
main.cpp: undefined reference to `glCreateProgramObjectARB'
/tmp/ccXPf0aL.o(.text+0x1c3):main.cpp: undefined reference to `glCreateShaderObjectARB'
/tmp/ccXPf0aL.o(.text+0x1e1):main.cpp: undefined reference to `glShaderSourceARB'
/tmp/ccXPf0aL.o(.text+0x1f2):main.cpp: undefined reference to `glCompileShaderARB'
/tmp/ccXPf0aL.o(.text+0x20f):main.cpp: undefined reference to `glGetObjectParameterivARB'
/tmp/ccXPf0aL.o(.text+0x258):main.cpp: undefined reference to `glGetInfoLogARB'
/tmp/ccXPf0aL.o(.text+0x2b2):main.cpp: undefined reference to `glAttachObjectARB'

What library do I need to add to gcc to link proper? Thanks for your time.

Try adding -lGL

That should be enough - since glsl is part of GL2.0 core, and implemented in the driver.
But it has to be a 2.0 lib. Be sure you also have the 2.0 libs in your library link path.

make sure that the necessary extensions are defined

Found it! I had to use the glXGetProcAddress. Then I came to some other problems but finally I’ve been able to resolve the situation :slight_smile: and start writing some of the shaders that are in the OpenGL Shading Language book.
But I’d like to take this opportunity and point out that the aforementioned book should provide a basic example of how one sets up a program to use shaders. It does provide snippets of settinp things up, but I couldn’t find a complete example, thus had to resort to an example from the internet.
Anyway, I’ve much to learn now that I know how to write shaders.

PS It’s a shame that ATI still don’t provide OpenGL 2.0 functionality in their driver yet. The version supported in the latest release is 1.3 in Linux.

there is the example with the basic pair of shaders and it is exactly this path you have to follow in order to set up your app for shaders …

like loading the source for a shader, compile it, provide it to the shader, attach it, create a program object, link the source and use the program object

Yes, I hadn’t read chapter 7 at the time I last posted. I just started reading it and things are becoming a lot clearer. My bad. I just expected to see an example including some glut initialization code. This is why I got lost.

dvm - sorry for going a bit off-topic here, but you mention ATi on Linux. I take it it’s working fine for you (other than GL version)?

There’s a very frustrated “ZigZag” lurking on the Linux forum. Maybe you can help him out?