On Jan 12, 2009, at 7:59 , Hadassa Brunschwig wrote:
Hi
I am trying to compile multiple .c functions into
a shared object using R CMD SHLIB (I am using Tiger 10.4.10).
These functions make use of header files, some of with are in
the same directory as the .c files and some of them are standard I
guess,
like #include <stdlib.h>.
When I compile the files using gcc, they compile beautifully. But
using the
following command
R CMD SHLIB -o test.so *.c
I obtain errors of the sort:
ld: multiple definitions of symbol _ivector
nrutil.o definition of _ivector in section (__TEXT,__text)
tools.o definition of _ivector in section (__TEXT,__text)
I read somewhere that this is due to multiple compilers but I am not
sure about that.
No, this is a bug in your code - it's because you have multiple
definitions of the same symbol (ivector). If you want the two symbols
to be the same across modules, you must declare it external in one of
the two files. If you want them separate, declare both static.
(One of the most common mistakes leading to this error is to use
definitions in header files).
Cheers,
S
I thought that I might have to add a statement for ld which says
--allow-multiple-definitions
but don't know where to put that in the R CMD SHLIB command. Or do I
have to include
the path to the standard libraries stdlib.h?
Thanks for any comments.
Hadassa
--
Hadassa Brunschwig
PhD Student
Department of Statistics
The Hebrew University of Jerusalem
http://www.stat.huji.ac.il
_______________________________________________
R-SIG-Mac mailing list
[email protected]
https://stat.ethz.ch/mailman/listinfo/r-sig-mac
_______________________________________________
R-SIG-Mac mailing list
[email protected]
https://stat.ethz.ch/mailman/listinfo/r-sig-mac