Reputation: 763
I want to write a simple SDL OpenGL app, Codeblocks is the IDE I use. When I create a new OpenGL project, it compiles fine, but if I try to use a function from the SDL header, le wild "undefined reference error" occurs. The same goes for the other direction, if I create a new SDL project, I can use the SDL functions without problems but I get a "undefined reference error" for the OpenGL functions...
NOTES:
Upvotes: 1
Views: 2373
Reputation: 10551
Asking pkg-config is the preferable thing for obtain the particular flags and options needed for compilation and linkage against SDL and Mesa's GL+GLU. (Some GL implemenetations may not be shipping .pc files, but they should still be used where available.)
Upvotes: 2
Reputation: 162164
You need to add the correct library. Headers just give the compiler sort of a index. But you need to tell the linker which libraries to actually pull in. You should find the linker options at the build settings. You need the following libraries for SDL + OpenGL
-lGL
linker switch )-lSDL
linker switch)You may also require libGLU.so if you're using glu… functions.
Upvotes: 2