|
google site
|
|||||||
| Forums | Register | Blog | Man Pages | Forum Rules | Links | Albums | FAQ | Users | Calendar | Search | Today's Posts | Mark Forums Read |
| 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. |
![]() |
|
|
Search this Thread |
|
#8
|
|||
|
|||
|
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
|
||||
|
||||
|
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
|
|||
|
|||
|
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
|
||||
|
||||
|
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
|
|||
|
|||
|
Thanks a lot. We do need one automated script that would do this all.
|
|
#13
|
|||
|
|||
|
Quote:
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 | ||
|
|
![]() |
| Thread Tools | Search this Thread |
| Display Modes | |
|
|
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 |