[R-SIG-Mac]Compiling R libraries on MAC OS X
Stephen Eglen
eglen@pcg.wustl.edu
Wed, 26 Feb 2003 19:29:58 -0600
Jan de Leeuw writes:
> If you use flat namespaces you cannot have multiple definitions of
> symbols,
> because the linked application has no way of knowing which definition
> you meant. There are a number of ways to deal with this. You can use
> two-level namespaces (which give warnings for multiple definitions)
>
> > gcc -bundle -bundle-loader /usr/local/lib/R/bin/R.bin -undefined error
> > -L/sw/lib -L/usr/local/lib -o sjevor.so edgelist.o geometry.o heap.o
> > main.o memory.o output.o sjevor.o voronoi.o
>
> You can change the C code such that all definitions but one use extern
> (this is best). And you can force the link by adding the
> -m flag, which also transforms errors to warnings, i.e.
>
> > gcc -bundle -flat_namespace -undefined suppress -Xlinker -m -L/sw/lib
> > -L/usr/local/lib -o sjevor.so edgelist.o geometry.o heap.o main.o
> > memory.o output.o sjevor.o voronoi.o
Thanks very much Jan for your help. I have updated the C code so that
the global variables are defined once, and then "extern"ed in other
files that need them. This works very well.
Stephen