PDA

View Full Version : Problem linking in dev-cpp



Rodrigo
08-04-2010, 11:03 AM
Hi guys.
I'm trying to use GLM library to load obj files.
I downloaded the files, created a project in dev-cpp with those files to generate a ".a" library.
Everything worked, no errors.

So I went back to my opengl project, added that .a to the linker and tried to compile, but I get compilation errors in .c files of the GLM, which I compiled before.

What could it be?
Here are the errors:



Compilador: Default compiler
Building Makefile: "C:\Documents and Settings\Rodrigo Barboza\Meus documentos\Gravidade\Makefile.win"
Executando make...
make.exe -f "C:\Documents and Settings\Rodrigo Barboza\Meus documentos\Gravidade\Makefile.win" all
gcc.exe pontos.o -o "Gravidade.exe" -L"C:/Dev-Cpp/lib" -lglut32 -lglu32 -lopengl32 glmlib.a

glmlib.a(glm.o)(.text+0x53c7):glm.c: undefined reference to `glDeleteTextures@8'
glmlib.a(glm.o)(.text+0x69aa):glm.c: undefined reference to `glDisable@4'
glmlib.a(glm.o)(.text+0x69e7):glm.c: undefined reference to `glTexEnvf@12'
glmlib.a(glm.o)(.text+0x6a0b):glm.c: undefined reference to `glLightModeli@8'
glmlib.a(glm.o)(.text+0x6a24):glm.c: undefined reference to `glLightModeli@8'
glmlib.a(glm.o)(.text+0x6aec):glm.c: undefined reference to `glBegin@4'
glmlib.a(glm.o)(.text+0x6bea):glm.c: undefined reference to `glEnd@0'
glmlib.a(glm.o)(.text+0x6c05):glm.c: undefined reference to `glBindTexture@8'
glmlib.a(glm.o)(.text+0x6c2d):glm.c: undefined reference to `glBindTexture@8'
glmlib.a(glm.o)(.text+0x6c3c):glm.c: undefined reference to `glBegin@4'
glmlib.a(glm.o)(.text+0x6cd1):glm.c: undefined reference to `glMaterialf@12'
glmlib.a(glm.o)(.text+0x6cef):glm.c: undefined reference to `glColor3fv@4'
glmlib.a(glm.o)(.text+0x6d19):glm.c: undefined reference to `glNormal3fv@4'
glmlib.a(glm.o)(.text+0x6da4):glm.c: undefined reference to `glNormal3fv@4'
glmlib.a(glm.o)(.text+0x6e99):glm.c: undefined reference to `glTexCoord2f@8'
glmlib.a(glm.o)(.text+0x6ef7):glm.c: undefined reference to `glVertex3fv@4'
glmlib.a(glm.o)(.text+0x6f13):glm.c: undefined reference to `glEnd@0'
glmlib.a(glm.o)(.text+0x6f6e):glm.c: undefined reference to `glBlendFunc@8'
glmlib.a(glm.o)(.text+0x6f7d):glm.c: undefined reference to `glDepthMask@4'
glmlib.a(glm.o)(.text+0x6f9c):glm.c: undefined reference to `glDepthMask@4'

glmlib.a(glm.o)(.text+0x6fab):glm.c: undefined reference to `glDisable@4'
glmlib.a(glm.o)(.text+0x6fc7):glm.c: undefined reference to `glGenLists@4'
glmlib.a(glm.o)(.text+0x6fe0):glm.c: undefined reference to `glNewList@8'
glmlib.a(glm.o)(.text+0x6ffa):glm.c: undefined reference to `glEndList@0'
glmlib.a(glmimg.o)(.text+0x45):glmimg.c: undefined reference to `glGetString@4'
glmlib.a(glmimg.o)(.text+0xfc):glmimg.c: undefined reference to `glGetIntegerv@8'
glmlib.a(glmimg.o)(.text+0x3fb):glmimg.c: undefined reference to `glPixelStorei@8'
glmlib.a(glmimg.o)(.text+0x414):glmimg.c: undefined reference to `glPixelStorei@8'
glmlib.a(glmimg.o)(.text+0x590):glmimg.c: undefined reference to `gluScaleImage@36'
glmlib.a(glmimg.o)(.text+0x5ba):glmimg.c: undefined reference to `glGenTextures@8'
glmlib.a(glmimg.o)(.text+0x5d1):glmimg.c: undefined reference to `glBindTexture@8'
glmlib.a(glmimg.o)(.text+0x654):glmimg.c: undefined reference to `glTexParameteri@12'
glmlib.a(glmimg.o)(.text+0x673):glmimg.c: undefined reference to `glTexParameteri@12'
glmlib.a(glmimg.o)(.text+0x6a8):glmimg.c: undefined reference to `glTexParameteri@12'
glmlib.a(glmimg.o)(.text+0x6dd):glmimg.c: undefined reference to `glTexParameteri@12'
glmlib.a(glmimg.o)(.text+0x720):glmimg.c: undefined reference to `glTexParameteri@12'
glmlib.a(glmimg.o)(.text+0x76b):glmimg.c: undefined reference to `glTexImage2D@36'
glmlib.a(glmimg.o)(.text+0x7ab):glmimg.c: undefined reference to `gluBuild2DMipmaps@28'
glmlib.a(glmimg.o)(.text+0x7f8):glmimg.c: undefined reference to `glTexImage2D@36'
glmlib.a(glm_util.o)(.text+0x1b3):glm_util.c: undefined reference to `glGetError@0'
glmlib.a(glm_util.o)(.text+0x1c7):glm_util.c: undefined reference to `gluErrorString@4'
collect2: ld returned 1 exit status

make.exe: *** [Gravidade.exe] Error 1

Execução terminada

marshats
08-05-2010, 09:46 AM
Order matters, try moving .a file before glut, gl, etc and add -lwinmm -lgdi32

something like


gcc.exe pontos.o glmlib.a -o "Gravidade.exe" -L"C:/Dev-Cpp/lib" -lglut32 -lglu32 -lopengl32 -lwinmm -lgdi32


This was tested and confirmed on an minGW/MSYS system with the projection example so it should correspond to how dev-cpp works behind the scenes:


gcc glm.c -c
ar rcs glmlib.a glm.o
gcc projection.c glmlib.a -lglut32 -lglu32 -lopengl32 -lwinmm -lgdi32

Rodrigo
08-05-2010, 09:47 AM
Thanks, I solved that too.
The order of the links was wrong. =P