loading D into R in OSX. Dynamic libraries problem

Michael lachmann at eva.mpg.de
Sat Jun 26 02:59:28 PDT 2010


I'm probably trying to complicate things too much while not really
understanding what I'm doing... I want to be able to call D code from R. (R is
a language for doing statistics)
When I try to load the code, I get an error:
dlopen( PATH/test.so, 6): Symbol not found: __minfo_beg

what I did is the following: I have a small D program:
--
import tango.io.Stdout;
extern (C) void Dfunc()
{
 Stdout("got to D").newline ;
}
--
I compile it with
dmd -fPIC -c test.d
then I make it into a dynamic library:
R CMD SHLIB   /usr/local/lib/libtango-user-dmd.a
/usr/local/lib/libtango-base-dmd-d.a test.o
which calls:
gcc -arch i386 -std=gnu99 -dynamiclib -Wl,-headerpad_max_install_names
-mmacosx-version-min=10.4 -undefined dynamic_lookup -single_module
-multiply_defined suppress -L/usr/local/lib -o test.so test.o
/usr/local/lib/libtango-user-dmd.a /usr/local/lib/libtango-base-dmd-d.a
-F/Library/Frameworks/R.framework/.. -framework R -Wl,-framework
-Wl,CoreFoundation

then I load the dynamic library into R, and get the above error.
dyn.load("test.so")

The equivalent in C works well:
--
#include <stdio.h>
void test()
{
   printf("got to C\n") ;
}
--
gcc -fPIC -c test.c
R CMD SHLIB test.o
which calls:
gcc -arch i386 -std=gnu99 -dynamiclib -Wl,-headerpad_max_install_names
-mmacosx-version-min=10.4 -undefined dynamic_lookup -single_module
-multiply_defined suppress -L/usr/local/lib -o test.so test.o
-F/Library/Frameworks/R.framework/.. -framework R -Wl,-framework
-Wl,CoreFoundation

At this point loading the resulting dynamic library from R causes no problems.

What am I doing wrong, other than trying to complicate things?


More information about the Digitalmars-d mailing list