18 Jan 17:13
glut and linking errors
Eric Lilja <mindcooler <at> gmail.com>
2006-01-18 16:13:22 GMT
2006-01-18 16:13:22 GMT
Hello, I checked out cvs sources of Mesa yesterday or the day before that, and I was able to build them successfully, including glut, on Windows using the very latest Visual C++. I couldn't build them with MinGW, however. Anyway, I need to use my freshly built Mesa binaries with Cygwin and my first problem was getting a simple test program to link. The test program involves calls to both gl, glu and glut-functions. I created .a-files of the three dll:s (opengl32, glu and glut) using these steps: pexports opengl32.DLL > opengl32.def dlltool --input-def opengl32.def --dllname opengl32.DLL --output-lib libopengl32.a -k pexports GLU32.DLL > glu32.def dlltool --input-def glu32.def --dllname GLU32.DLL --output-lib libglu32.a -k pexports GLUT32.DLL > glut32.def dlltool --input-def glut32.def --dllname GLUT32.DLL --output-lib libglut32.a -k Then, I copied the resulting .a-files to Cygwin's /usr/lib/w32api directory. But, when I try to build my simple test program, I get undefined references for all calls to glut-functions. The Makefile is: CC = gcc CFLAGS = -Wall -W -ansi -pedantic -g -O0 -I/home/mikael/mesacvs/Mesa/include -DWIN32 -c -o LDFLAGS = -lopengl32 -lglu32 -lglut32 -o $(EXEC) EXEC = 1-9.exe OBJECTS = simple1_9.o all: $(OBJECTS) $(CC) $^ $(LDFLAGS) %.o: %.c $(CC) $(CFLAGS) $@ $< clean: rm -f $(OBJECTS) $(EXEC) *~ *.stackdump Here's the exact error when building my test program: $ make gcc -Wall -W -ansi -pedantic -g -O0 -I/home/mikael/mesacvs/Mesa/include -DWIN32 -c -o simple1_9.o simple1_9.c gcc simple1_9.o -lopengl32 -lglu32 -lglut32 -o 1-9.exe simple1_9.o: In function `idle': /home/mikael/coding/kurser/datorgrafik/lab1/1-9/simple1_9.c:25: undefined reference to `_glutPostRedisplay' simple1_9.o: In function `display': /home/mikael/coding/kurser/datorgrafik/lab1/1-9/simple1_9.c:128: undefined reference to `_glutSwapBuffers' simple1_9.o: In function `main': /home/mikael/coding/kurser/datorgrafik/lab1/1-9/simple1_9.c:166: undefined reference to `_glutInit' /home/mikael/coding/kurser/datorgrafik/lab1/1-9/simple1_9.c:167: undefined reference to `_glutInitDisplayMode' /home/mikael/coding/kurser/datorgrafik/lab1/1-9/simple1_9.c:168: undefined reference to `_glutInitWindowPosition' /home/mikael/coding/kurser/datorgrafik/lab1/1-9/simple1_9.c:169: undefined reference to `_glutInitWindowSize' /home/mikael/coding/kurser/datorgrafik/lab1/1-9/simple1_9.c:170: undefined reference to `_glutCreateWindow' /home/mikael/coding/kurser/datorgrafik/lab1/1-9/simple1_9.c:187: undefined reference to `_glutDisplayFunc' /home/mikael/coding/kurser/datorgrafik/lab1/1-9/simple1_9.c:188: undefined reference to `_glutReshapeFunc' /home/mikael/coding/kurser/datorgrafik/lab1/1-9/simple1_9.c:189: undefined reference to `_glutKeyboardFunc' /home/mikael/coding/kurser/datorgrafik/lab1/1-9/simple1_9.c:190: undefined reference to `_glutIdleFunc' /home/mikael/coding/kurser/datorgrafik/lab1/1-9/simple1_9.c:191: undefined reference to `_glutMainLoop' collect2: ld returned 1 exit status make: *** [all] Error 1 So, I used nm to check the first undefined function it complains about, glutPostRedisplay: $ nm /usr/lib/w32api/libglut32.a | grep _glutPostRedisplay 00000000 T __glutPostRedisplay <at> 0 00000000 I __imp___glutPostRedisplay <at> 0 So, it's there but it's decorated (hope that's the correct term). Then I check a function in libopengl32.a my program calls that I dont get an undefined reference for: $ nm /usr/lib/w32api/libopengl32.a | grep _glPopMatrix 00000000 I __imp__glPopMatrix 00000000 T _glPopMatrix It's there, of course, but unlike the glut-functions, no decorations. So I use sed to remove stuff from the glut-def-file (before creating the .a-file using dlltool): # I'm sure these four lines can be turned into one. cat glut32.def | sed 's/^_//' > glut32.def.temp mv glut32.def.temp glut32.def cat glut32.def | sed -e 's/@.*//' > glut32.def.temp mv glut32.def.temp glut32.def And now the program links successfully! But, it doesn't help me, because when I try to run the resulting executable I get an error message box saying: The procedure entry point glutCreateWindow could not be located in the dynamic link library GLUT32.DLL glutCreateWindow is the fifth call to a glut function my program makes. It seems to be able to call glutInit(), glutInitDisplayMode(), glutInitWindowPosition(), and glutInitWindowSize() correctly, but I'm not sure about that. I don't understand these tools well enough to solve it, but surely here does? I would be very grateful for any assistance. I don't know how it works, but it seems the programs loads the DLL at runtime and since I've tampered with the decorations it cannot find any functions. But how can I get the program to link if I dont tamper with the decorations?? Please help if you can! / E ------------------------------------------------------- This SF.net email is sponsored by: Splunk Inc. Do you grep through log files for problems? Stop! Download the new AJAX search engine that makes searching your log files as easy as surfing the web. DOWNLOAD SPLUNK! http://sel.as-us.falkag.net/sel?cmd=lnk&kid=103432&bid=230486&dat=121642
RSS Feed