Author Topic: linker error : undefined referece to gl functions, even using -lopengl32  (Read 10621 times)

diegowb

  • Guest

Hi people

I was just trying to compile a project in C::B and I got "... undefined referece to ..." messages to all opengl functions used by a static library being linked with the aplication.
(WinXP using C::B version 1.0rc2 with gcc)

The link libraries in the application are (in order they are entered) :

mingw32, winmm, opengl32, glu32, SDLmain, SDL, SDL_image, lib3d.a (the last is my lib)

the compiler directories:
  C:\Arquivos de programas\CodeBlocks\include
  C:\c\include
and linker directories
  C:\Arquivos de programas\CodeBlocks\lib
  C:\c\lib
  ..

SDL headers are in c:\c\include\SDL. The SDL .a files and my lib3d.a in c:\c\lib

The headers of my lib are in a up directorie

Here is the begin of the build log :

Project   : A3D Viewer
Compiler  : GNU GCC Compiler (called directly)
Directory : C:\Documents and Settings\Administrador\Meus documentos\Meus Projetos\A3D\modelViewer\
--------------------------------------------------------------------------------
Switching to target: default
mingw32-g++.exe   -Wall -g  -Wall -g   -I..  -I"C:\Arquivos de programas\CodeBlocks\include" -IC:\c\include -c modelViewer.cpp -o .objs\modelViewer.o
mingw32-g++.exe    -L"C:\Arquivos de programas\CodeBlocks\lib" -LC:\c\lib -o SDLapp.exe .objs\modelViewer.o        -lmingw32 -lwinmm -lopengl32 -lglu32 -lSDLmain -lSDL -lSDL_image -l3d
C:\c\lib/lib3d.a(motor.o): In function `ZN3a3d5Motor8prepararEv':
C:/Documents and Settings/Administrador/Meus documentos/Meus Projetos/A3D/motor.cpp:170: undefined reference to `[email protected]'
C:/Documents and Settings/Administrador/Meus documentos/Meus Projetos/A3D/motor.cpp:173: undefined reference to `[email protected]'
C:/Documents and Settings/Administrador/Meus documentos/Meus Projetos/A3D/motor.cpp:177: undefined reference to `[email protected]'
C:/Documents and Settings/Administrador/Meus documentos/Meus Projetos/A3D/motor.cpp:178: undefined reference to `[email protected]'
C:/Documents and Settings/Administrador/Meus documentos/Meus Projetos/A3D/motor.cpp:179: undefined reference to `[email protected]'
C:/Documents and Settings/Administrador/Meus documentos/Meus Projetos/A3D/motor.cpp:180: undefined reference to `[email protected]'
C:/Documents and Settings/Administrador/Meus documentos/Meus Projetos/A3D/motor.cpp:183: undefined reference to `[email protected]'
C:/Documents and Settings/Administrador/Meus documentos/Meus Projetos/A3D/motor.cpp:185: undefined reference to `[email protected]'
C:/Documents and Settings/Administrador/Meus documentos/Meus Projetos/A3D/motor.cpp:190: undefined reference to `[email protected]'
C:/Documents and Settings/Administrador/Meus documentos/Meus Projetos/A3D/motor.cpp:191: undefined reference to `[email protected]'
C:/Documents and Settings/Administrador/Meus documentos/Meus Projetos/A3D/motor.cpp:192: undefined reference to `[email protected]'
C:/Documents and Settings/Administrador/Meus documentos/Meus Projetos/A3D/motor.cpp:193: undefined reference to `[email protected]'
C:/Documents and Settings/Administrador/Meus documentos/Meus Projetos/A3D/motor.cpp:195: undefined reference to `[email protected]'
C:/Documents and Settings/Administrador/Meus documentos/Meus Projetos/A3D/motor.cpp:197: undefined reference to `[email protected]'
C:/Documents and Settings/Administrador/Meus documentos/Meus Projetos/A3D/motor.cpp:199: undefined reference to `[email protected]'
C:/Documents and Settings/Administrador/Meus documentos/Meus Projetos/A3D/motor.cpp:200: undefined reference to `[email protected]'
C:/Documents and Settings/Administrador/Meus documentos/Meus Projetos/A3D/motor.cpp:201: undefined reference to `[email protected]'
C:/Documents and Settings/Administrador/Meus documentos/Meus Projetos/A3D/motor.cpp:202: undefined reference to `[email protected]'
C:\c\lib/lib3d.a(motor.o): In function `ZN3a3d5Motor14executarCamadaEPNS_6CamadaE':
C:/Documents and Settings/Administrador/Meus documentos/Meus Projetos/A3D/motor.cpp:247: undefined reference to `[email protected]'
C:/Documents and Settings/Administrador/Meus documentos/Meus Projetos/A3D/motor.cpp:264: undefined reference to `[email protected]'
C:\c\lib/lib3d.a(motor.o): In function `ZN3a3d6Camada13prepararLuzesEv':
C:/Documents and Settings/Administrador/Meus documentos/Meus Projetos/A3D/motor.cpp:301: undefined reference to `[email protected]'
.
.
.
continue with more undefind reference messages...
.
.
.

The OpenGL template and SDL template works fine.
Also, if a copy the aplication source files to my library project and compile it as a console application instead of a static library (adding the librarys to the linker of course), it links without problem with OpenGL and a get an executable.

I read the seemed topics but didn't figure out wat is wrong in my project.

Please, can anyone help me ?
Thanks by now and sorry for my bad english

PS: I don't know if it matters by here is the build log of the library

Project   : A3D
Compiler  : GNU GCC Compiler (called directly)
Directory : C:\Documents and Settings\Administrador\Meus documentos\Meus Projetos\A3D\
--------------------------------------------------------------------------------
Switching to target: default
mingw32-g++.exe    -Wall -g    -I"C:\Arquivos de programas\CodeBlocks\include" -IC:\c\include -c camera.cpp -o .objs\camera.o
mingw32-g++.exe    -Wall -g    -I"C:\Arquivos de programas\CodeBlocks\include" -IC:\c\include -c carregadorASE.cpp -o .objs\carregadorASE.o
mingw32-g++.exe    -Wall -g    -I"C:\Arquivos de programas\CodeBlocks\include" -IC:\c\include -c imagem.cpp -o .objs\imagem.o
mingw32-g++.exe    -Wall -g    -I"C:\Arquivos de programas\CodeBlocks\include" -IC:\c\include -c leitor.cpp -o .objs\leitor.o
mingw32-g++.exe    -Wall -g    -I"C:\Arquivos de programas\CodeBlocks\include" -IC:\c\include -c luz.cpp -o .objs\luz.o
mingw32-g++.exe    -Wall -g    -I"C:\Arquivos de programas\CodeBlocks\include" -IC:\c\include -c malha.cpp -o .objs\malha.o
mingw32-g++.exe    -Wall -g    -I"C:\Arquivos de programas\CodeBlocks\include" -IC:\c\include -c memoria.cpp -o .objs\memoria.o
mingw32-g++.exe    -Wall -g    -I"C:\Arquivos de programas\CodeBlocks\include" -IC:\c\include -c modelo.cpp -o .objs\modelo.o
mingw32-g++.exe    -Wall -g    -I"C:\Arquivos de programas\CodeBlocks\include" -IC:\c\include -c modelosFabrica.cpp -o .objs\modelosFabrica.o
mingw32-g++.exe    -Wall -g    -I"C:\Arquivos de programas\CodeBlocks\include" -IC:\c\include -c motor.cpp -o .objs\motor.o
mingw32-g++.exe    -Wall -g    -I"C:\Arquivos de programas\CodeBlocks\include" -IC:\c\include -c objGeom.cpp -o .objs\objGeom.o
mingw32-g++.exe    -Wall -g    -I"C:\Arquivos de programas\CodeBlocks\include" -IC:\c\include -c objParam.cpp -o .objs\objParam.o
mingw32-g++.exe    -Wall -g    -I"C:\Arquivos de programas\CodeBlocks\include" -IC:\c\include -c pele.cpp -o .objs\pele.o
mingw32-g++.exe    -Wall -g    -I"C:\Arquivos de programas\CodeBlocks\include" -IC:\c\include -c textura.cpp -o .objs\textura.o
ar.exe -r c:\c\lib\lib3d.a .objs\camera.o .objs\carregadorASE.o .objs\imagem.o .objs\leitor.o .objs\luz.o .objs\malha.o .objs\memoria.o .objs\modelo.o .objs\modelosFabrica.o .objs\motor.o .objs\objGeom.o .objs\objParam.o .objs\pele.o .objs\textura.o
   ranlib c:\c\lib\lib3d.a
ar.exe: creating c:\c\lib\lib3d.a
Process terminated with status 0 (0 minutes, 16 seconds)
0 errors, 0 warnings



Offline mandrav

  • Project Leader
  • Administrator
  • Lives here!
  • *****
  • Posts: 4291
    • Code::Blocks IDE
Change the order of the link libraries. Order matters...
Because lib3d.a requires libopengl32.a, libopengl32.a must appear after lib3d.a in the linker command line.
Be patient!
This bug will be fixed soon...

diegowb

  • Guest
thanks mandrav, it works now.

I did know that order do influence, but I thought that depended librarys comes before dependent ones, but it seems to be the inverse.  :?

Thanks again. :D