You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Now that issue 11478 is partially fixed (linktime shared libraries), on to runtime loaded shared libraries:
----
module foo;
import std.stdio;
extern(C) void foo1(){
printf("ok1
");
import core.runtime;
bool ret=Runtime.initialize(); //is it necessary?
printf("ret=%d
",ret);
printf("ok2
");
writeln("ok3");
int[]a;
a.length=2; //ok
writeln(a.length); //dmd2.062 only crashes at this point
}
----
module main2;
import std.stdio, core.sys.posix.dlfcn;
void main(){
string file="libfoo.dylib";
auto handle = dlopen(file.ptr, RTLD_LAZY | RTLD_GLOBAL);
auto funptr = cast(void function()) dlsym(handle, "foo1");
funptr();
}
----
dmd -oflibfoo.dylib -shared foo.d;
dmd main.d
./main
--output:
2.062:
crashes at writeln(a.length) (lldb shows it crashes inside LockingTextWriter), which can still be useful for writing plugins.
git head: crashes upon loading
Also, note that dlopen() of a D shared library works when called from a C++ file, and that a C++ file can call multiple D shared libraries simultaneously when using RTLD_LAZY option.
Before waiting for a full solution with an integrated druntime, is there at least a way to have a separate runtime in each shared library, so that dlopen() can be called from a D file?
The text was updated successfully, but these errors were encountered:
Timothee Cour (@timotheecour) reported this on 2014-02-18T00:44:37Z
Transferred from https://issues.dlang.org/show_bug.cgi?id=12190
CC List
Description
The text was updated successfully, but these errors were encountered: