943,579 Members | Top Members by Rank

Ad:
  • C++ Discussion Thread
  • Marked Solved
  • Views: 751
  • C++ RSS
Jun 12th, 2009
0

Static libary has undefined references

Expand Post »
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:

C++ Syntax (Toggle Plain Text)
  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)

C++ Syntax (Toggle Plain Text)
  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

C++ Syntax (Toggle Plain Text)
  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?
Similar Threads
Reputation Points: 69
Solved Threads: 28
Posting Whiz
Clockowl is offline Offline
376 posts
since May 2008
Jun 12th, 2009
0

Re: Static libary has undefined references

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?
Reputation Points: 57
Solved Threads: 5
Light Poster
sysop_fb is offline Offline
42 posts
since Apr 2009
Jun 13th, 2009
0

Re: Static libary has undefined references

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.
Reputation Points: 69
Solved Threads: 28
Posting Whiz
Clockowl is offline Offline
376 posts
since May 2008

This thread is solved

Either the thread starter or a moderator has marked this thread as solved. You can most likely trust the responses and answers given. There is most likely no reason for any further responses to be posted here. If you have a related question, please start a new thread in this forum instead.

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in C++ Forum Timeline: Returning all installed network printers
Next Thread in C++ Forum Timeline: Best Approach To solve this..





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC