Go Back   The UNIX and Linux Forums > Top Forums > Emergency UNIX and Linux Support !! Help Me!!
google site



Emergency UNIX and Linux Support !! Help Me!! Post your urgent questions here for highest visibility. Posting a new thread to this forum requires Bits. We monitor this forum to help people with emergencies, but we do not guarantee response time or answers. This forum is "best effort" only. Members who reply to posts here receive a bonus of 1000 Bits per reply.

Closed Thread
English Japanese Spanish French German Portuguese Italian Powered by Powered by Google
 
Search this Thread
  #8  
Old 12-20-2009
Registered User
 

Join Date: May 2008
Posts: 52
Thanks: 0
Thanked 0 Times in 0 Posts
It seems that earlier developers to save effort on there end included all libraries within our project workspace which would be around 500. Now we are coding a separate test module which includes some objects referenced in the makefile. We created a new makefile for same and inclusion of some libraries for generating binary is giving hundreds of 'undefined reference' symbol error.
Sponsored Links
  #9  
Old 12-20-2009
otheus's Avatar
otheus otheus is offline Forum Advisor  
Moderator ala Mode
 

Join Date: Feb 2007
Location: Innsbruck, Austria
Posts: 1,908
Thanks: 0
Thanked 0 Times in 0 Posts
Are you using GNU Make? It has some tools builtin to find your dependencies, build static dependency files, and copious debug output. You can use these to achieve your goals.
  #10  
Old 12-20-2009
Registered User
 

Join Date: May 2008
Posts: 52
Thanks: 0
Thanked 0 Times in 0 Posts
Though we are not using GNU make, but right now we are in dead need to know that amongst the 500 libraries if I using some of them then what are the others which I can remove from my new makefile.

Please provide some reference for same.
  #11  
Old 12-20-2009
fpmurphy's Avatar
Moderator
 

Join Date: Dec 2003
Location: /dev/ph
Posts: 2,483
Thanks: 0
Thanked 38 Times in 37 Posts
Here is a genetic way of doing it

Use the nm utility to ouput the symbol table for your application. A 'T' in the second column indicates a function that is either defined in your source code or comes from a static library. A 'U' in the second column indicates a function that is included via a shared library. You then need to massage that list (listA) to remove all the functions that are defined within your source code.

Next write a script to nm each of your 500 libraries and construct a sorted list (listB) of library + function names.

Finally write a script which uses listB to update listA by adding a column containing the name of the library where that function is defined.

At this stage you should have a list of all the external functions used by your application together with the name of library which defined the function.

It is then a trivial exercise to figure out which libraries are not needed by the application.
  #12  
Old 12-25-2009
Registered User
 

Join Date: May 2008
Posts: 52
Thanks: 0
Thanked 0 Times in 0 Posts
Thanks a lot. We do need one automated script that would do this all.
  #13  
Old 02-09-2010
Registered User
 

Join Date: Jan 2010
Posts: 40
Thanks: 0
Thanked 0 Times in 0 Posts
Quote:
Originally Posted by uunniixx View Post
This is what I want to avoid - hit and trial method, the problem will get worse when inclusion of one object / static library file I have another dependency. Further this will take lots of workload and days to drive it to completion
I don't think that trial/error would be so tough. In pseudo perl code:


Code:
my @all_libs  = split (/\s+/, `ls $LIBPATH/*.a`);
my $good_libs = "";

# get number of unresolved messages w/o any static lib:
my $n_symbols = `make target | grep 'unresolved' | wc -l`;
chomp ($n_symbols);

foreach my $lib ( @all_libs )
{
  # try to add that static lib, and see if the number of unresolved syms decreases

  $lib =~ s/^lib//;
  $lib =~ s/\.a$//;
  
  my $check = `/bin/env LDFLAGS=-l$lib make target | grep 'unresolved' | wc -l`;
  chomp ($check);

  if ( $check < $n_symbols )
  {
     # good lib, well done!
     $good_libs .= " -l$lib");
  }    
}

# we want to link against all good libs
print "$good_libs\n";

You may getting symbols resolved twice - but that is a situation you should have stumbled over previously, so I guess thats unlikely. In any case, that will be simplier then the more formal, and elegant , way via nm, which was proposed earlier.

The above won't work if some of your static libs depend on other static libs - in that case, you need to add those 'good' libs you found to the test linking step.

Last edited by Andre_Merzky; 02-09-2010 at 04:14 AM.. Reason: simplified code
Sponsored Links
Closed Thread

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
awk - need to remove unwanted newlines on match Bubnoff Shell Programming and Scripting 6 08-18-2009 04:24 PM
Remove unwanted packages fugitive Solaris 4 06-04-2009 11:21 AM
How to Remove the unwanted Blank Lines Ariean UNIX for Advanced & Expert Users 5 01-28-2009 01:20 PM
Remove unwanted XML Tags ambals123 Shell Programming and Scripting 1 12-22-2007 04:34 AM
Remove unwanted data? hitmansilentass Shell Programming and Scripting 24 05-09-2007 10:50 AM



All times are GMT -4. The time now is 12:15 AM.