ranlib+xcode HOWTO
ranlib+xcode HOWTO
- Subject: ranlib+xcode HOWTO
- From: Eric Friedman <email@hidden>
- Date: Sun, 8 May 2005 17:56:02 -0700
I didn't find any hints online about this, and since I bothered to
figure it out, I'm posting for the benefit of others who look in the
archive.
The problem: you are using version control and have static libraries
that you keep checked in with your project (libeSellerate.a, for
example).
Checking out the library causes its modification timestamp to be more
recent than the timestamp in the library itself, and your build fails
because ld insists that you first run ranlib.
You realize that running ranlib to modify the library will result in a
lot of unnecessary thrash in your version control system and would
like to avoid that.
The solution: copy the libraries to your intermediate build area, run
ranlib on them there, and link them from there. The following summary
describes one approach to implementing this with Xcode.
HOWTO: Add a build phase to your build target (look for the target in
Groups & Files, expand it, and add a new "Run Script" build phase
somewhere before "Link Binary with Libraries."
The Build Phase should be defined with input/output arguments so that
you get "build avoidance" -- don't want it to execute if everything is
up to date (which it will be, except if you do a "clean" on the
target).
The input arguments are the library files. Since I keep those in the
root of my project, no path qualifier is needed, as that it is the
current working directory when the script is executed.
The output arguments are the library files with a directory prefix.
You could use a number of choices -- I chose $(TARGET_TEMP_DIR).
Finally, you need to write a script that copies each of the input
files to the corresponding output files and runs ranlib(1) on the
output files.
Here's mine, which uses /usr/bin/perl as the "shell" (through the
magic of unix's shebang, it doesn't have to actually be a shell
script)
my $input_count = $ENV{SCRIPT_INPUT_FILE_COUNT};
my $output_count = $ENV{SCRIPT_OUTPUT_FILE_COUNT};
if (defined $input_count && defined $output_count && $input_count ==
$output_count) {
for (my $i = 0; $i < $input_count; $i++) {
my $src = $ENV{"SCRIPT_INPUT_FILE_$i"};
my $dest = $ENV{"SCRIPT_OUTPUT_FILE_$i"};
system('/bin/cp', $src, $dest);
system('/usr/bin/ranlib', $dest);
}
exit 0;
} else {
print STDERR "Input/output count either undefined or not equal";
exit 1;
}
You can then add the directory where you copied the archive files to
your target's Library Search Paths so that the linker can find them.
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden