GTK+ Forums Forum Index GTK+ Forums
Discussion forum for GTK+ and Programming. Ask questions, troubleshoot problems, view and post example code, or express your opinions.
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

multiple static libraries

 
Post new topic   Reply to topic    GTK+ Forums Forum Index -> GTK+ Programming
Author Message
dreblen
Never Seen the Sunlight


Joined: 14 Jun 2007
Posts: 409
Location: Falun, WI USA

PostPosted: Thu May 15, 2008 4:54 pm    Post subject: multiple static libraries Reply with quote

Hi,
maybe I'm just having a brain lapse, but this is really getting to me, so I figured I'd ask for help.

I have two static libraries (libncString, libncUI), libncUI calls functions from libncString.
In my testing program, if I call a function in libncUI that depends on libncString, it will give undefined reference errors, but if I call an ncString function somewhere in my test program, it compiles and runs just fine.

examples:
Code: (C)
1
2
3
/* this one fails to link */
/* nc_menu_add_menu() calls nc_strip_char(), which is in libncString */
nc_menu_add_menu(&NC_MENUBAR(mbar)->mdat, "/", "File");


Code: (C)
1
2
3
/* this one links and runs fine */
nc_strip_char("test", 't');
nc_menu_add_menu(&NC_MENUBAR(mbar)->mdat, "/", "File");


if I'm missing something, I'd really appreciate some help.
Thanks...
Back to top
dreblen
Never Seen the Sunlight


Joined: 14 Jun 2007
Posts: 409
Location: Falun, WI USA

PostPosted: Thu May 15, 2008 7:05 pm    Post subject: Reply with quote

okay, it turns out it was just an error in my link command (-lncString wasn't in the spot it should have been).
however, I'm still curious as to why it compiles fine if I have a call to an ncString function in my test program.
Thanks...


Last edited by dreblen on Thu May 15, 2008 7:16 pm; edited 1 time in total
Back to top
idelovski



Joined: 21 Oct 2007
Posts: 4

PostPosted: Thu May 15, 2008 7:07 pm    Post subject: Reply with quote

Try reversing libraries in your make file. If I understand you well, I think
this is documented feature of linkers - they are optimizing unused code.
Back to top
dreblen
Never Seen the Sunlight


Joined: 14 Jun 2007
Posts: 409
Location: Falun, WI USA

PostPosted: Thu May 15, 2008 7:16 pm    Post subject: Reply with quote

yes idelovski, that was the problem, I looked up gcc linker options ( http://gcc.gnu.org/onlinedocs/gcc-3.4.6/gcc/Link-Options.html#Link-Options ) and corrected it.
Thank you.
Back to top
Display posts from previous:   
Post new topic   Reply to topic    GTK+ Forums Forum Index -> GTK+ Programming All times are GMT
Page 1 of 1

 


Powered by phpBB © 2001, 2005 phpBB Group
CodeBB 1.0 Beta 2
Protected by Anti-Spam ACP