please help

I have coppied the following code from a book:
#include <gl/glut.h>

int main(int argc, char **argv) {
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_DEPTH | GLUT_SINGLE | GLUT_RGBA);
glutInitWindowPosition(100,100);
glutInitWindowSize(320,320);
glutCreateWindow(“3D Tech- GLUT Tutorial”);

}

It compiles nicely but when I try to link it I get the following errors:

C:\MinGW\bin>g++ -o test test.o
test.o(.text+0x15):test.cpp: undefined reference to __glutInitWithExit@12' test.o(.text+0x32):test.cpp: undefined reference to__glutCreateWindowWithExit@
8’
test.o(.text+0x50):test.cpp: undefined reference to `__glutCreateMenuWithExit@8’

test.o(.text+0xa8):test.cpp: undefined reference to glutInitDisplayMode@4' test.o(.text+0xb7):test.cpp: undefined reference toglutInitWindowPosition@8’
test.o(.text+0xcc):test.cpp: undefined reference to `glutInitWindowSize@8’

What am I doing wrong?

  • can it have something to do with me not having the .dll files: opengl32 and gl32? (I have the glut32.dll)
  • and if so where do I get them.

thanks

Try downloading the windows GLUT lib’s .h, and dll files from here:
http://www.xmission.com/~nate/opengl.html

Originally posted by Swiftwing:
[b]I have coppied the following code from a book:
#include <gl/glut.h>

int main(int argc, char **argv) {
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_DEPTH | GLUT_SINGLE | GLUT_RGBA);
glutInitWindowPosition(100,100);
glutInitWindowSize(320,320);
glutCreateWindow(“3D Tech- GLUT Tutorial”);

}

It compiles nicely but when I try to link it I get the following errors:

C:\MinGW\bin>g++ -o test test.o
test.o(.text+0x15):test.cpp: undefined reference to __glutInitWithExit@12' test.o(.text+0x32):test.cpp: undefined reference to __glutCreateWindowWithExit@
8’
test.o(.text+0x50):test.cpp: undefined reference to `__glutCreateMenuWithExit@8’

test.o(.text+0xa8):test.cpp: undefined reference to glutInitDisplayMode@4' test.o(.text+0xb7):test.cpp: undefined reference to glutInitWindowPosition@8’
test.o(.text+0xcc):test.cpp: undefined reference to `glutInitWindowSize@8’

What am I doing wrong?

  • can it have something to do with me not having the .dll files: opengl32 and gl32? (I have the glut32.dll)
  • and if so where do I get them.

thanks[/b]

thanks - but I allready did that!

Originally posted by nexusone:
[b]Try downloading the windows GLUT lib’s .h, and dll files from here:
http://www.xmission.com/~nate/opengl.html

[/b]

Do you have the “glut32.lib” file included in your linker settings?
The glut32.dll is only called when the program is run.

Do your have the library file that if compatiable with your compiler, the one from nates site is for MSVC++ only. Unless your compiler reads MSVC library files, you will need to convert or find one for your compiler.

Originally posted by Swiftwing:
[b]thanks - but I allready did that!

[/b]

[This message has been edited by nexusone (edited 10-11-2002).]

[QUOTE]Originally posted by nexusone:
[b]Do you have the “glut32.lib” file included in your linker settings?

  • I really don’t know - how do i do that? / how do I check it?

The glut32.dll is only called when the program is run.

  • I know - strangly enough…

Do your have the library file that is compatiable with your compiler, the one from nates site is for MSVC++ only.
Unless your compiler reads MSVC library files, you will need to convert or find one for your compiler.

  • I havn’t converted anything - how do I do that? - I’m using the minGW compiler.

[This message has been edited by Swiftwing (edited 10-13-2002).]

If you had downloaded the files from nate robins site you should have also got a file called glut32.lib, which should be put in the /lib/ directory in your compilers directory.

Then you will have to add the glut32.lib to your linker settings if you have not done so already.

The glut32.dll is only needed when the program is run, not during the compiling of the program.

I can not tell you anything about the mingw, other then a lot of people have problems.

Maybe better you try the free compiler I use… lcc-win32, nice GUI interface, and I have no problems making GLUT programs.

Just do a google search for lcc-win32…

Originally posted by Swiftwing:
[b][QUOTE]Originally posted by nexusone:
[b]Do you have the “glut32.lib” file included in your linker settings?

  • I really don’t know - how do i do that? / how do I check it?

The glut32.dll is only called when the program is run.

  • I know - strangly enough…

Do your have the library file that is compatiable with your compiler, the one from nates site is for MSVC++ only.
Unless your compiler reads MSVC library files, you will need to convert or find one for your compiler.

  • I havn’t converted anything - how do I do that? - I’m using the minGW compiler.

[This message has been edited by Swiftwing (edited 10-13-2002).][/b]