Static libary has undefined references

Please support our C++ advertiser: Intel Parallel Studio Home
Thread Solved

Join Date: May 2008
Posts: 374
Reputation: Clockowl is on a distinguished road 
Solved Threads: 27
Clockowl's Avatar
Clockowl Clockowl is offline Offline
Posting Whiz

Static libary has undefined references

 
0
  #1
Jun 12th, 2009
Hey guys,

So I have compiled my first home-written static library (named PixGUI) that happens to call OpenGL functions. However, I noticed that when compiling (using MinGWs GCC with Code::Blocks project set to "static library") it doesn't matter whether I supply the linker with libopengl32.a or not, it simply compiles each time.

However, when I link PixGUI to another project, i.e. Pixlings, and try to compile that, it gives me these errors:

  1. ||=== Pixlings, Release ===|
  2. ..\PixGUI\lib\libPixGUI.a(button.o):button.cpp:(.text+0xc1)||undefined reference to `glColor3fv@4'|
  3. ..\PixGUI\lib\libPixGUI.a(button.o):button.cpp:(.text+0xea)||undefined reference to `glRectf@16'|
  4. ||=== Build finished: 2 errors, 0 warnings ===|

The build log of libPixGUI.a (without supplying the linker with opengl32, but doesn't matter for undefined references)

  1. -------------- Build: Release in PixGUI ---------------
  2.  
  3. Compiling: element.cpp
  4. Compiling: engine.cpp
  5. Compiling: window.cpp
  6. Compiling: button.cpp
  7. Linking static library: lib\libPixGUI.a
  8. ar.exe: creating lib\libPixGUI.a
  9. Output size is 39.72 KB
  10. Process terminated with status 0 (0 minutes, 2 seconds)
  11. 0 errors, 0 warnings

Build log of Pixlings

  1. -------------- Build: Debug in Pixlings ---------------
  2.  
  3. Compiling: Program.cpp
  4. Compiling: game.cpp
  5. Compiling: main.cpp
  6. Compiling: Menu.cpp
  7. Linking console executable: bin\Debug\Pixlings.exe
  8. ..\PixGUI\lib\libPixGUI.a(button.o):button.cpp:(.text+0xc1): undefined reference to `glColor3fv@4'
  9. ..\PixGUI\lib\libPixGUI.a(button.o):button.cpp:(.text+0xea): undefined reference to `glRectf@16'
  10. collect2: ld returned 1 exit status
  11. Process terminated with status 1 (0 minutes, 1 seconds)
  12. 2 errors, 0 warnings

How would I solve these undefined references?
Reply With Quote Quick reply to this message  
Join Date: Apr 2009
Posts: 39
Reputation: sysop_fb is an unknown quantity at this point 
Solved Threads: 5
sysop_fb sysop_fb is offline Offline
Light Poster

Re: Static libary has undefined references

 
0
  #2
Jun 12th, 2009
Well I'd say you're probably not prototyping the functions you want to use from your library properly. Did you write a head file for your library and extern the prototypes?
Reply With Quote Quick reply to this message  
Join Date: May 2008
Posts: 374
Reputation: Clockowl is on a distinguished road 
Solved Threads: 27
Clockowl's Avatar
Clockowl Clockowl is offline Offline
Posting Whiz

Re: Static libary has undefined references

 
0
  #3
Jun 13th, 2009
Hehe, I messed up the linking order.

Say that Program A depends on Lib B, and A and B contain references to Lib C, then A needs to supply B before C, not after.
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC