PDA

View Full Version : Metrowerks CodeWarrior Linking



andyg
06-11-2002, 01:58 AM
Help please! Complete Newbie using the above compiler am unable to link even the most simple app:
----------------------------------------
#include <windows.h>
#include <freeglut.h>
using namespace std;
int main(int argc, char** argv)
{

glutInit(&argc, argv);
}
---------------------------
Error given is:
Link error: Undefined symbol: __imp__glutInit@8
---------------------------
Am I using the wrong library? Also, I had to alter the embedded include directives from

#include "GL\gl.h" to #include "gl.h"

in order to get anywhere....

Any suggestions much appreciated!

Gavin
06-11-2002, 02:40 AM
dunno about the pc, but if on mac make sure you have all the necesarry stubs and resource files in your project.

Deiussum
06-11-2002, 04:29 AM
I don't know why, but a lot of people in the C++ class I had to take at school had the same misconception you seem to have.

Doing this..

#include <glut.h>

Is not adding the library.

.h files are what are called header files, not libraries. That means that they contain prototypes for functions, etc. They do not contain the object code for those functions. That object code is what is contained in the actual library. The actual library has an extension like .lib or .a or .so etc. depending on the compiler.

To add a library, you need to tell the linker which library to link in to the final binary. I'm not sure exactly how this is done with CodeWarrior, but somone else may be able to tell you how. You should look for some project setting that lets you specify libraries/object modules, etc.

Hope this helps. http://www.opengl.org/discussion_boards/ubb/smile.gif

Gavin
06-12-2002, 12:51 AM
In codewarrior you just drag them to the project window. i.e. if on mac add the GLLibraryStub etc.
glut.lib
glut.rsrc

andyg
06-12-2002, 07:14 AM
that's great - thanks guys, problem sorted!