I've been trying to compile this example for PNG texture mapping in OpenGL that I found here: http://www.wyatt100.freeserve.co.uk/ I'm not even sure what system it was compiled for, but I figured I'd try out the library. I'm having an unusual linker error though, as you will see...because it does not appear to be related to the library, instead it seems to relate to GLUT. Well, here is the information you need:
(1)I'm working on Windows XP with version 4.9.9.2 of Dev-C++
(2)Here's the code:
/
* Test program for glpng
* by Ben Wyatt ben@wyatt100.freeserve.co.uk
* Featuring a shameless plug for my stunt course program
* Available from the same site as glpng
* http://www.wyatt100.freeserve.co.uk/download.htm /
include <gl/glpng.h>
include <gl/glut.h>
include <stdlib.h>
int angle = 0;
/** GLUT callback functions **/
void KeyPress(unsigned char key, int x, int y) {
switch (key) {
case 27: /ESC/ glutDestroyWindow(glutGetWindow()); exit(0); break;
}
}
(3)It compiles... but doesn't link!:
Compiler: For GLPNG
Executing gcc.exe...
gcc.exe "C:\Documents and Settings\Megan Bednarz\My Documents_School Files!VIZA\PaperDragon\TextureTest_Lars\GLPNGTest\Test.c" -o "C:\Documents and Settings\Megan Bednarz\My Documents_School Files!VIZA\PaperDragon\TextureTest_Lars\GLPNGTest\Test.exe" -I"C:\Dev-Cpp\include" -L"C:\Dev-Cpp\lib" -lopengl32 -lglut32 -lglu32
C:\DOCUME~1\MEGANB~1\LOCALS~1\Temp/ccK0baaa.o(.text+0x1c):Test.c: undefined reference to __glutInitWithExit'
C:\DOCUME~1\MEGANB~1\LOCALS~1\Temp/ccK0baaa.o(.text+0x37):Test.c: undefined reference to__glutCreateWindowWithExit'
C:\DOCUME~1\MEGANB~1\LOCALS~1\Temp/ccK0baaa.o(.text+0x52):Test.c: undefined reference to __glutCreateMenuWithExit'
C:\DOCUME~1\MEGANB~1\LOCALS~1\Temp/ccK0baaa.o(.text+0x70):Test.c: undefined reference toglutGetWindow'
C:\DOCUME~1\MEGANB~1\LOCALS~1\Temp/ccK0baaa.o(.text+0x78):Test.c: undefined reference to glutDestroyWindow'
C:\DOCUME~1\MEGANB~1\LOCALS~1\Temp/ccK0baaa.o(.text+0xc9):Test.c: undefined reference toglutPostRedisplay'
C:\DOCUME~1\MEGANB~1\LOCALS~1\Temp/ccK0baaa.o(.text+0xed):Test.c: undefined reference to _imp__glClear'
C:\DOCUME~1\MEGANB~1\LOCALS~1\Temp/ccK0baaa.o(.text+0xf4):Test.c: undefined reference to_impglLoadIdentity'
C:\DOCUME~1\MEGANB~1\LOCALS~1\Temp/ccK0baaa.o(.text+0x115):Test.c: undefined reference to _imp__glTranslatef'
C:\DOCUME~1\MEGANB~1\LOCALS~1\Temp/ccK0baaa.o(.text+0x140):Test.c: undefined reference to_impglRotatef'
C:\DOCUME~1\MEGANB~1\LOCALS~1\Temp/ccK0baaa.o(.text+0x14e):Test.c: undefined reference to _imp__glBegin'
C:\DOCUME~1\MEGANB~1\LOCALS~1\Temp/ccK0baaa.o(.text+0x166):Test.c: undefined reference to_impglTexCoord2f'
C:\DOCUME~1\MEGANB~1\LOCALS~1\Temp/ccK0baaa.o(.text+0x188):Test.c: undefined reference to `_impglVertex3f'
C:\DOCUME~1\MEGANB~1\LOCALS~1\Temp/ccK0baaa.o(.text+0x1a0):Test.c: undefined reference to `_imp__glTexCoord2f'
C:\DOCUME~1\MEGANB~1\LOCALS~1\Temp/ccK0baaa.o(.text+0x1bd):Test.c: undefined reference to _imp__glVertex3f'
C:\DOCUME~1\MEGANB~1\LOCALS~1\Temp/ccK0baaa.o(.text+0x1d5):Test.c: undefined reference to_impglTexCoord2f'
C:\DOCUME~1\MEGANB~1\LOCALS~1\Temp/ccK0baaa.o(.text+0x1f7):Test.c: undefined reference to _imp__glVertex3f'
C:\DOCUME~1\MEGANB~1\LOCALS~1\Temp/ccK0baaa.o(.text+0x20f):Test.c: undefined reference to_impglTexCoord2f'
C:\DOCUME~1\MEGANB~1\LOCALS~1\Temp/ccK0baaa.o(.text+0x236):Test.c: undefined reference to _imp__glVertex3f'
C:\DOCUME~1\MEGANB~1\LOCALS~1\Temp/ccK0baaa.o(.text+0x24e):Test.c: undefined reference to_impglTexCoord2f'
C:\DOCUME~1\MEGANB~1\LOCALS~1\Temp/ccK0baaa.o(.text+0x275):Test.c: undefined reference to _imp__glVertex3f'
C:\DOCUME~1\MEGANB~1\LOCALS~1\Temp/ccK0baaa.o(.text+0x28d):Test.c: undefined reference to_impglTexCoord2f'
C:\DOCUME~1\MEGANB~1\LOCALS~1\Temp/ccK0baaa.o(.text+0x2af):Test.c: undefined reference to _imp__glVertex3f'
C:\DOCUME~1\MEGANB~1\LOCALS~1\Temp/ccK0baaa.o(.text+0x2c7):Test.c: undefined reference to_impglTexCoord2f'
C:\DOCUME~1\MEGANB~1\LOCALS~1\Temp/ccK0baaa.o(.text+0x2e4):Test.c: undefined reference to `_impglVertex3f'
C:\DOCUME~1\MEGANB~1\LOCALS~1\Temp/ccK0baaa.o(.text+0x2fc):Test.c: undefined reference to `_imp__glTexCoord2f'
C:\DOCUME~1\MEGANB~1\LOCALS~1\Temp/ccK0baaa.o(.text+0x31e):Test.c: undefined reference to _imp__glVertex3f'
C:\DOCUME~1\MEGANB~1\LOCALS~1\Temp/ccK0baaa.o(.text+0x325):Test.c: undefined reference to_impglEnd'
C:\DOCUME~1\MEGANB~1\LOCALS~1\Temp/ccK0baaa.o(.text+0x32c):Test.c: undefined reference to glutSwapBuffers'
C:\DOCUME~1\MEGANB~1\LOCALS~1\Temp/ccK0baaa.o(.text+0x356):Test.c: undefined reference to_impglViewport'
C:\DOCUME~1\MEGANB~1\LOCALS~1\Temp/ccK0baaa.o(.text+0x364):Test.c: undefined reference to _imp__glMatrixMode'
C:\DOCUME~1\MEGANB~1\LOCALS~1\Temp/ccK0baaa.o(.text+0x36b):Test.c: undefined reference to_impglLoadIdentity'
C:\DOCUME~1\MEGANB~1\LOCALS~1\Temp/ccK0baaa.o(.text+0x397):Test.c: undefined reference to _imp__gluPerspective'
C:\DOCUME~1\MEGANB~1\LOCALS~1\Temp/ccK0baaa.o(.text+0x3a5):Test.c: undefined reference to_impglMatrixMode'
C:\DOCUME~1\MEGANB~1\LOCALS~1\Temp/ccK0baaa.o(.text+0x3e4):Test.c: undefined reference to glutInitDisplayMode'
C:\DOCUME~1\MEGANB~1\LOCALS~1\Temp/ccK0baaa.o(.text+0x3f8):Test.c: undefined reference toglutInitWindowSize'
C:\DOCUME~1\MEGANB~1\LOCALS~1\Temp/ccK0baaa.o(.text+0x43f):Test.c: undefined reference to pngBind'
C:\DOCUME~1\MEGANB~1\LOCALS~1\Temp/ccK0baaa.o(.text+0x494):Test.c: undefined reference to_impglEnable'
C:\DOCUME~1\MEGANB~1\LOCALS~1\Temp/ccK0baaa.o(.text+0x4a9):Test.c: undefined reference to _imp__glBindTexture'
C:\DOCUME~1\MEGANB~1\LOCALS~1\Temp/ccK0baaa.o(.text+0x4b7):Test.c: undefined reference to_impglEnable'
C:\DOCUME~1\MEGANB~1\LOCALS~1\Temp/ccK0baaa.o(.text+0x4d8):Test.c: undefined reference to _imp__glColor3f'
C:\DOCUME~1\MEGANB~1\LOCALS~1\Temp/ccK0baaa.o(.text+0x4e6):Test.c: undefined reference toglutKeyboardFunc'
C:\DOCUME~1\MEGANB~1\LOCALS~1\Temp/ccK0baaa.o(.text+0x4f2):Test.c: undefined reference to glutIdleFunc'
C:\DOCUME~1\MEGANB~1\LOCALS~1\Temp/ccK0baaa.o(.text+0x4fe):Test.c: undefined reference toglutDisplayFunc'
C:\DOCUME~1\MEGANB~1\LOCALS~1\Temp/ccK0baaa.o(.text+0x50a):Test.c: undefined reference to glutReshapeFunc'
C:\DOCUME~1\MEGANB~1\LOCALS~1\Temp/ccK0baaa.o(.text+0x50f):Test.c: undefined reference toglutMainLoop'
collect2: ld returned 1 exit status
Execution terminated
So, there are the mandatory 3 bits of info. I thought I followed all directions properly, but I am probably missing something very obvious...
Oh, so the strange part is: these seem to be errors related to GLUT, even though I've been actually using GLUT successfully for other programs I have run. I don't quite remember where I got the GLUT library... probably from opengl.org, so that could be one of the problems. I also might not be linking the png texture mapping header file right, or it could be made wrong and I might have to recompile the source code (oh I don't even want to think about that...at least it comes with source code, though). The download came with an html file of how to use it and where to put all the files. It's part of that Zip file from the website I gave before.
Okay, I think my brain has had enough... I will turn it over to you guys, the pros. Thanks for all your time in helping me and others with our silly problems! I greatly appreciate any feedback you can give me on these errors.
--Megan
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Anonymous
-
2007-11-20
Try changing the link order to:
-lglut32 -lglu32 -lopengl32
or use grouping:
-( -lglut32 -lglu32 -lopengl32 -)
Link order is significant since by default the linker only makes one pass at each library in the order listed on the command line. A symbol cannot be introduced in a library that is not resolved in the same library or a later one. The linker only carries forward unresolved symbols, not symbols that may or may not be needed by subsequent libraries.
The grouping solution using -( <library list> -) causes the linker to iterate the group until no further symbols are resolved - it is necessary for libraries with circular dependencies and is otherwise a quick-and-dirty way of not having to figure out the order of dependency. It increases build time which may or may not be significant depending on the size of the project and the order you list the libraries.
Other than that, you obviously took a look at the "Read First" thread, but failed to observe teh advice about paths containing spaces: "C:\Documents and Settings\Megan Bednarz\My Documents" is not an advisable location for your project. It also apparently reveals your full name, which you may consider a privacy issue.
Clifford
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Anonymous
-
2007-11-20
... and "_School Files"
Clifford
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Clifford, thanks for taking a look at this! I'll try the grouping solution if changing the order doesn't work. I tried changing the order before, but I will try it again.
Good advice on the spaces in filenames... I like to keep my files organized, but having them all in My Documents seems to be a bad decision, at least for these programs.
Well, I'll try these and see what I come up with!
Thanks,
--Megan
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi,
I've been trying to compile this example for PNG texture mapping in OpenGL that I found here: http://www.wyatt100.freeserve.co.uk/ I'm not even sure what system it was compiled for, but I figured I'd try out the library. I'm having an unusual linker error though, as you will see...because it does not appear to be related to the library, instead it seems to relate to GLUT. Well, here is the information you need:
(1)I'm working on Windows XP with version 4.9.9.2 of Dev-C++
(2)Here's the code:
/
* Test program for glpng
* by Ben Wyatt ben@wyatt100.freeserve.co.uk
* Featuring a shameless plug for my stunt course program
* Available from the same site as glpng
* http://www.wyatt100.freeserve.co.uk/download.htm
/
include <gl/glpng.h>
include <gl/glut.h>
include <stdlib.h>
int angle = 0;
/** GLUT callback functions **/
void KeyPress(unsigned char key, int x, int y) {
switch (key) {
case 27: /ESC/ glutDestroyWindow(glutGetWindow()); exit(0); break;
}
}
void Update(void) {
angle = (angle+1)%360;
glutPostRedisplay();
}
void Display(void) {
const float w = 2, h = 2;
}
void Reshape(int w, int h) {
glViewport(0, 0, w, h);
}
/** Main function **/
int main() {
pngInfo info;
GLuint texture;
}
(3)It compiles... but doesn't link!:
Compiler: For GLPNG
Executing gcc.exe...
gcc.exe "C:\Documents and Settings\Megan Bednarz\My Documents_School Files!VIZA\PaperDragon\TextureTest_Lars\GLPNGTest\Test.c" -o "C:\Documents and Settings\Megan Bednarz\My Documents_School Files!VIZA\PaperDragon\TextureTest_Lars\GLPNGTest\Test.exe" -I"C:\Dev-Cpp\include" -L"C:\Dev-Cpp\lib" -lopengl32 -lglut32 -lglu32
C:\DOCUME~1\MEGANB~1\LOCALS~1\Temp/ccK0baaa.o(.text+0x1c):Test.c: undefined reference to
__glutInitWithExit' C:\DOCUME~1\MEGANB~1\LOCALS~1\Temp/ccK0baaa.o(.text+0x37):Test.c: undefined reference to
__glutCreateWindowWithExit'C:\DOCUME~1\MEGANB~1\LOCALS~1\Temp/ccK0baaa.o(.text+0x52):Test.c: undefined reference to
__glutCreateMenuWithExit' C:\DOCUME~1\MEGANB~1\LOCALS~1\Temp/ccK0baaa.o(.text+0x70):Test.c: undefined reference to
glutGetWindow'C:\DOCUME~1\MEGANB~1\LOCALS~1\Temp/ccK0baaa.o(.text+0x78):Test.c: undefined reference to
glutDestroyWindow' C:\DOCUME~1\MEGANB~1\LOCALS~1\Temp/ccK0baaa.o(.text+0xc9):Test.c: undefined reference to
glutPostRedisplay'C:\DOCUME~1\MEGANB~1\LOCALS~1\Temp/ccK0baaa.o(.text+0xed):Test.c: undefined reference to
_imp__glClear' C:\DOCUME~1\MEGANB~1\LOCALS~1\Temp/ccK0baaa.o(.text+0xf4):Test.c: undefined reference to
_impglLoadIdentity'C:\DOCUME~1\MEGANB~1\LOCALS~1\Temp/ccK0baaa.o(.text+0x115):Test.c: undefined reference to
_imp__glTranslatef' C:\DOCUME~1\MEGANB~1\LOCALS~1\Temp/ccK0baaa.o(.text+0x140):Test.c: undefined reference to
_impglRotatef'C:\DOCUME~1\MEGANB~1\LOCALS~1\Temp/ccK0baaa.o(.text+0x14e):Test.c: undefined reference to
_imp__glBegin' C:\DOCUME~1\MEGANB~1\LOCALS~1\Temp/ccK0baaa.o(.text+0x166):Test.c: undefined reference to
_impglTexCoord2f'C:\DOCUME~1\MEGANB~1\LOCALS~1\Temp/ccK0baaa.o(.text+0x188):Test.c: undefined reference to `_impglVertex3f'
C:\DOCUME~1\MEGANB~1\LOCALS~1\Temp/ccK0baaa.o(.text+0x1a0):Test.c: undefined reference to `_imp__glTexCoord2f'
C:\DOCUME~1\MEGANB~1\LOCALS~1\Temp/ccK0baaa.o(.text+0x1bd):Test.c: undefined reference to
_imp__glVertex3f' C:\DOCUME~1\MEGANB~1\LOCALS~1\Temp/ccK0baaa.o(.text+0x1d5):Test.c: undefined reference to
_impglTexCoord2f'C:\DOCUME~1\MEGANB~1\LOCALS~1\Temp/ccK0baaa.o(.text+0x1f7):Test.c: undefined reference to
_imp__glVertex3f' C:\DOCUME~1\MEGANB~1\LOCALS~1\Temp/ccK0baaa.o(.text+0x20f):Test.c: undefined reference to
_impglTexCoord2f'C:\DOCUME~1\MEGANB~1\LOCALS~1\Temp/ccK0baaa.o(.text+0x236):Test.c: undefined reference to
_imp__glVertex3f' C:\DOCUME~1\MEGANB~1\LOCALS~1\Temp/ccK0baaa.o(.text+0x24e):Test.c: undefined reference to
_impglTexCoord2f'C:\DOCUME~1\MEGANB~1\LOCALS~1\Temp/ccK0baaa.o(.text+0x275):Test.c: undefined reference to
_imp__glVertex3f' C:\DOCUME~1\MEGANB~1\LOCALS~1\Temp/ccK0baaa.o(.text+0x28d):Test.c: undefined reference to
_impglTexCoord2f'C:\DOCUME~1\MEGANB~1\LOCALS~1\Temp/ccK0baaa.o(.text+0x2af):Test.c: undefined reference to
_imp__glVertex3f' C:\DOCUME~1\MEGANB~1\LOCALS~1\Temp/ccK0baaa.o(.text+0x2c7):Test.c: undefined reference to
_impglTexCoord2f'C:\DOCUME~1\MEGANB~1\LOCALS~1\Temp/ccK0baaa.o(.text+0x2e4):Test.c: undefined reference to `_impglVertex3f'
C:\DOCUME~1\MEGANB~1\LOCALS~1\Temp/ccK0baaa.o(.text+0x2fc):Test.c: undefined reference to `_imp__glTexCoord2f'
C:\DOCUME~1\MEGANB~1\LOCALS~1\Temp/ccK0baaa.o(.text+0x31e):Test.c: undefined reference to
_imp__glVertex3f' C:\DOCUME~1\MEGANB~1\LOCALS~1\Temp/ccK0baaa.o(.text+0x325):Test.c: undefined reference to
_impglEnd'C:\DOCUME~1\MEGANB~1\LOCALS~1\Temp/ccK0baaa.o(.text+0x32c):Test.c: undefined reference to
glutSwapBuffers' C:\DOCUME~1\MEGANB~1\LOCALS~1\Temp/ccK0baaa.o(.text+0x356):Test.c: undefined reference to
_impglViewport'C:\DOCUME~1\MEGANB~1\LOCALS~1\Temp/ccK0baaa.o(.text+0x364):Test.c: undefined reference to
_imp__glMatrixMode' C:\DOCUME~1\MEGANB~1\LOCALS~1\Temp/ccK0baaa.o(.text+0x36b):Test.c: undefined reference to
_impglLoadIdentity'C:\DOCUME~1\MEGANB~1\LOCALS~1\Temp/ccK0baaa.o(.text+0x397):Test.c: undefined reference to
_imp__gluPerspective' C:\DOCUME~1\MEGANB~1\LOCALS~1\Temp/ccK0baaa.o(.text+0x3a5):Test.c: undefined reference to
_impglMatrixMode'C:\DOCUME~1\MEGANB~1\LOCALS~1\Temp/ccK0baaa.o(.text+0x3e4):Test.c: undefined reference to
glutInitDisplayMode' C:\DOCUME~1\MEGANB~1\LOCALS~1\Temp/ccK0baaa.o(.text+0x3f8):Test.c: undefined reference to
glutInitWindowSize'C:\DOCUME~1\MEGANB~1\LOCALS~1\Temp/ccK0baaa.o(.text+0x43f):Test.c: undefined reference to
pngBind' C:\DOCUME~1\MEGANB~1\LOCALS~1\Temp/ccK0baaa.o(.text+0x494):Test.c: undefined reference to
_impglEnable'C:\DOCUME~1\MEGANB~1\LOCALS~1\Temp/ccK0baaa.o(.text+0x4a9):Test.c: undefined reference to
_imp__glBindTexture' C:\DOCUME~1\MEGANB~1\LOCALS~1\Temp/ccK0baaa.o(.text+0x4b7):Test.c: undefined reference to
_impglEnable'C:\DOCUME~1\MEGANB~1\LOCALS~1\Temp/ccK0baaa.o(.text+0x4d8):Test.c: undefined reference to
_imp__glColor3f' C:\DOCUME~1\MEGANB~1\LOCALS~1\Temp/ccK0baaa.o(.text+0x4e6):Test.c: undefined reference to
glutKeyboardFunc'C:\DOCUME~1\MEGANB~1\LOCALS~1\Temp/ccK0baaa.o(.text+0x4f2):Test.c: undefined reference to
glutIdleFunc' C:\DOCUME~1\MEGANB~1\LOCALS~1\Temp/ccK0baaa.o(.text+0x4fe):Test.c: undefined reference to
glutDisplayFunc'C:\DOCUME~1\MEGANB~1\LOCALS~1\Temp/ccK0baaa.o(.text+0x50a):Test.c: undefined reference to
glutReshapeFunc' C:\DOCUME~1\MEGANB~1\LOCALS~1\Temp/ccK0baaa.o(.text+0x50f):Test.c: undefined reference to
glutMainLoop'collect2: ld returned 1 exit status
Execution terminated
So, there are the mandatory 3 bits of info. I thought I followed all directions properly, but I am probably missing something very obvious...
Oh, so the strange part is: these seem to be errors related to GLUT, even though I've been actually using GLUT successfully for other programs I have run. I don't quite remember where I got the GLUT library... probably from opengl.org, so that could be one of the problems. I also might not be linking the png texture mapping header file right, or it could be made wrong and I might have to recompile the source code (oh I don't even want to think about that...at least it comes with source code, though). The download came with an html file of how to use it and where to put all the files. It's part of that Zip file from the website I gave before.
Okay, I think my brain has had enough... I will turn it over to you guys, the pros. Thanks for all your time in helping me and others with our silly problems! I greatly appreciate any feedback you can give me on these errors.
--Megan
Try changing the link order to:
-lglut32 -lglu32 -lopengl32
or use grouping:
-( -lglut32 -lglu32 -lopengl32 -)
Link order is significant since by default the linker only makes one pass at each library in the order listed on the command line. A symbol cannot be introduced in a library that is not resolved in the same library or a later one. The linker only carries forward unresolved symbols, not symbols that may or may not be needed by subsequent libraries.
The grouping solution using -( <library list> -) causes the linker to iterate the group until no further symbols are resolved - it is necessary for libraries with circular dependencies and is otherwise a quick-and-dirty way of not having to figure out the order of dependency. It increases build time which may or may not be significant depending on the size of the project and the order you list the libraries.
Other than that, you obviously took a look at the "Read First" thread, but failed to observe teh advice about paths containing spaces: "C:\Documents and Settings\Megan Bednarz\My Documents" is not an advisable location for your project. It also apparently reveals your full name, which you may consider a privacy issue.
Clifford
... and "_School Files"
Clifford
Clifford, thanks for taking a look at this! I'll try the grouping solution if changing the order doesn't work. I tried changing the order before, but I will try it again.
Good advice on the spaces in filenames... I like to keep my files organized, but having them all in My Documents seems to be a bad decision, at least for these programs.
Well, I'll try these and see what I come up with!
Thanks,
--Megan