undefined symbol: _Dmain when loading library at runtime on Linux

FreeSlave freeslave93 at gmail.com
Sun Sep 29 17:12:55 PDT 2013


On Sunday, 29 September 2013 at 23:40:21 UTC, David Nadlinger 
wrote:
> The short answer is: Shared D libraries, especially dynamically 
> loading them, is not supported by LDC. We are going implement 
> this once upstream druntime actually supports runtime loading 
> (2.064). So, even the versions that "work fine" do so just by 
> accident. There are much bigger problems that this, even with 
> compile-time linked shared libraries.
>
> dlfcn - you mean libdl?
>
> David

Yes, libdl. dlfcn if header's name. Well, this "by accident" is 
not so bad, I've just checked dynamic loading of C++ class in 
ldmd2 - it works. But I'm not sure how to build C++ library to 
set D function as exception handler properly (for rethrowing). It 
worked with dmd in this way:
//dmd cppexception.d -c
extern(C) void cppRethrower()
{
     throw new Exception("Cpp exception");
}
//g++ cppfiles.cpp cppexception.o
extern "C" { void cppRethrower(); }
std::set_terminate(cppRethrower); //somewhere

Anyway, wait for good support of shared libraries by all D 
compiler, I'm very interested in that because I write library 
helping to load plugins at runtime ( 
https://bitbucket.org/FreeSlave/dido )


More information about the digitalmars-d-ldc mailing list