D shared libraries
BB
b.buderman at gmail.com
Fri Apr 11 08:13:30 PDT 2008
Tried this on D.gnu but didn't get an answer. Any feedback here?
------------------------------------------------------------------
From what I read on newsgroups, this should be possible with gdc on
linux? Goal is a plugin type solution. With the following code, I
compile intf.d and lib.d together into a shared library, and intf.d and
main.d into an executable. Compiles/links fine. When I run it, I get a
message like:
Null library handle: libxyz.so.1.0.1: undefined symbol: __data_start
I compiled the .d files with -fPIC and the .so with:
gcc -shared -Wl,-soname,libxyz.so.1 -fPIC.
Is this definitely possible, and if so, what am I doing wrong? I tried
gdc 0.24 and the latest off svn with the same results.
TIA.
-------------------------------------------------------------
intf.d:
=========
module intf;
public interface I { public int getId(); }
lib.d:
=========
module lib;
import intf;
class A : I { public int getId() { return 42; } }
extern (C) { I getObj() { return new A(); } }
main.d:
==========
...
void main(char[][] args)
{
void* hnd = dlopen(toStringz("libxyz.so.1.0.1"), RTLD_NOW);
if (hnd == null) {
printf("Null library handle: %s\n", dlerror());
return 0;
}
...
}
More information about the Digitalmars-d
mailing list