Metrowerks CodeWarrior Linking

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!

dunno about the pc, but if on mac make sure you have all the necesarry stubs and resource files in your project.

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.

In codewarrior you just drag them to the project window. i.e. if on mac add the GLLibraryStub etc.

that’s great - thanks guys, problem sorted!