Creating and loading static libraries differes from other OSes?
Creating and loading static libraries differes from other OSes?
- Subject: Creating and loading static libraries differes from other OSes?
- From: Malte Tancred <email@hidden>
- Date: Fri, 14 Dec 2001 14:48:06 +0100
Hi!
I sent this message some time ago but didn't receive any
answer. There must be someone who knows what's going
on. :-)
Thanks,
Malte
Begin forwarded message:
I've tried to find information here on the list on compiling
static libraries on Mac OS X 10.1. I read something just the
other day stating that the tools depend on specific names
for different types of libraries, ie .a for static libraries and
.dyld for dynamic libraries.
Now, I'm trying to compile an open source product where
all c files are (by default) compiled with:
cc -c file.c
Many of these .o-files are grouped together in static libraries
with the commands:
ar cr library.a o-files...
ranlib library.a
Programs are then loaded by issuing the following command:
cc -s -o program program.o <other .o-files and .a-files>
This is the default setup that works just fine on for example
OpenBSD and slackware linux.
When running with this configuration (except for the -s option
which isn't supported on Mac OS X) I get the following warning
late in the build process, building one of several programs:
/usr/bin/ld: Undefined symbols:
_strerr_sys
/usr/bin/ld: warning unused multiple definitions of symbol _puts
ofmipd.o definition of _puts in section (__TEXT,__text)
/usr/lib/libSystem.dylib(puts.o) unused definition of _puts
strerr_sys is already compiled into one of the libraries and that
library's been used earlier on in the build process for another program.
Two things come to mind:
1. libSystem.dylib is a dynamic library. I'm compiling static libraries.
2. Mixing .o and .a files as source file for the linker might not work
as expected. Is the order a problem on Mac OS X.
I've tried adding -static to both the compile and link phase to make
sure everything is compiled statically. This results in the following
line:
/usr/bin/ld: can't locate file for: -lcrt0.o
Isn't it possible to compile statically linked programs on Mac OS X?
Any ideas welcome!
Cheerio,
Malte
--
Malte Tancred
Computer programmer, Oops AB, Sweden
mailto:email@hidden
http://www.oops.se/
_______________________________________________
cocoa-dev mailing list
email@hidden
http://www.lists.apple.com/mailman/listinfo/cocoa-dev