Hello,
I am trying to compile hello.c example from the redbook. I am using CodeBlocks and/or Dev-C++ and get the same error:
Project : Console application
Compiler : GNU GCC Compiler (called directly)
Directory : C:\Documents and Settings\kostya\My Documents\cpp est7\Switching to target: default
Compiling: hello.c
Linking console executable: C:\Documents and Settings\kostya\My Documents\cpp est7\console1.exe
.objs\hello.o:hello.c:(.text+0x1c): undefined reference to__glutInitWithExit' .objs\hello.o:hello.c:(.text+0x37): undefined reference to
__glutCreateWindowWithExit’
.objs\hello.o:hello.c:(.text+0x52): undefined reference to__glutCreateMenuWithExit' .objs\hello.o:hello.c:(.text+0x66): undefined reference to
_imp__glClear’
.objs\hello.o:hello.c:(.text+0x87): undefined reference to_imp__glColor3f' .objs\hello.o:hello.c:(.text+0x95): undefined reference to
_imp__glBegin’
.objs\hello.o:hello.c:(.text+0xb6): undefined reference to_imp__glVertex3f' .objs\hello.o:hello.c:(.text+0xd7): undefined reference to
_imp__glVertex3f’
.objs\hello.o:hello.c:(.text+0xf8): undefined reference to_imp__glVertex3f' .objs\hello.o:hello.c:(.text+0x119): undefined reference to
_imp__glVertex3f’
.objs\hello.o:hello.c:(.text+0x120): undefined reference to_imp__glEnd' .objs\hello.o:hello.c:(.text+0x127): undefined reference to
_imp__glFlush’
.objs\hello.o:hello.c:(.text+0x159): undefined reference to_imp__glClearColor' .objs\hello.o:hello.c:(.text+0x167): undefined reference to
_imp__glMatrixMode’
.objs\hello.o:hello.c:(.text+0x16e): undefined reference to_imp__glLoadIdentity' .objs\hello.o:hello.c:(.text+0x19c): undefined reference to
_imp__glOrtho’
.objs\hello.o:hello.c:(.text+0x1e8): undefined reference toglutInitDisplayMode' .objs\hello.o:hello.c:(.text+0x1fc): undefined reference to
glutInitWindowSize’
.objs\hello.o:hello.c:(.text+0x210): undefined reference toglutInitWindowPosition' .objs\hello.o:hello.c:(.text+0x22d): undefined reference to
glutDisplayFunc’
.objs\hello.o:hello.c:(.text+0x232): undefined reference to `glutMainLoop’
collect2: ld returned 1 exit status
Process terminated with status 1 (0 minutes, 0 seconds)
0 errors, 0 warnings
When I add
Project : Console application
Compiler : GNU GCC Compiler (called directly)
Directory : C:\Documents and Settings\kostya\My Documents\cpp est7\Switching to target: default
Compiling: hello.c
Linking console executable: C:\Documents and Settings\kostya\My Documents\cpp est7\console1.exe
.objs\hello.o:hello.c:(.text+0x1c): undefined reference to__glutInitWithExit@12' .objs\hello.o:hello.c:(.text+0x3c): undefined reference to
__glutCreateWindowWithExit@8’
.objs\hello.o:hello.c:(.text+0x5c): undefined reference to `__glutCreateMenuWithExit@8’
collect2: ld returned 1 exit status
Process terminated with status 1 (0 minutes, 0 seconds)
0 errors, 0 warnings
It’s obvious that it’s the linker error.
I linked files as suggested ( C::B forum ) in the following order
opengl32, glu32, glut32, however it doesn’t effect anything at all. Help me, please, what am I doing wrong here?
Thank you!