|
Archives
D Programming
DD.gnu digitalmars.D digitalmars.D.bugs digitalmars.D.dtl digitalmars.D.ide digitalmars.D.dwt digitalmars.D.announce digitalmars.D.learn digitalmars.D.debugger C/C++ Programming
c++c++.announce c++.atl c++.beta c++.chat c++.command-line c++.dos c++.dos.16-bits c++.dos.32-bits c++.idde c++.mfc c++.rtl c++.stl c++.stl.hp c++.stl.port c++.stl.sgi c++.stlsoft c++.windows c++.windows.16-bits c++.windows.32-bits c++.wxwindows digitalmars.empire digitalmars.DMDScript electronics |
D.gnu - D shared libraries
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;
}
...
}
Apr 09 2008
BB wrote: Apr 11 2008
|