User forums > Using Code::Blocks
Problems linking libraries
yaustar:
Hiya,
Tried compiling several demos and its all fine till I reach any that needs libraries (eg OpenGL).
Errors I get are:
Main.cpp undefined reference to 'glViewport@16'
Main.cpp undefined reference to 'glMatrixMode@4'
etc
I have tried linking them under
Project -> Build Options -> Linker (under both release and debug and root)
Also the code has
--- Code: ---#pragma comment(lib, "opengl32.lib")
#pragma comment(lib, "glu32.lib")
--- End code ---
So I cant see whats wrong.... can someone give me a step by step guide in case I am missing anything stupid...
Thanks
thomas:
Those are libraries you need to link with to build basic OpenGL applications.
Either add -lopengl32 -lglu32 to "other linker options", or add opengl32 and glu32 to link libraries on the left, or link against opengl32.dll and glu32.dll which are both found inside WINDOWS\system32.
yaustar:
--- Quote from: thomas on September 15, 2005, 08:00:06 pm ---Those are libraries you need to link with to build basic OpenGL applications.
Either add -lopengl32 -lglu32 to "other linker options", or add opengl32 and glu32 to link libraries on the left, or link against opengl32.dll and glu32.dll which are both found inside WINDOWS\system32.
--- End quote ---
Ooooookay.... the -lopengl32 and -lglu32 in other linker options worked.... my next question is why and what does it actually do when you do that?
rickg22:
-l is the GCC command to link a library. For some reason adding them to the linker libraries list didn't work in your case.... (weird)
mandrav:
--- Quote from: rickg22 on September 15, 2005, 09:19:42 pm ----l is the GCC command to link a library. For some reason adding them to the linker libraries list didn't work in your case.... (weird)
--- End quote ---
It's not exactly "weird"...
He used #pragmas to link the libraries. These only work in MS compilers...
Navigation
[0] Message Index
[#] Next page
Go to full version