How to use std. packages in so files written in dlang

grampus via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Thu Aug 11 17:57:42 PDT 2016


Hi,erveryone
I am trying to use dLang to make so file for existing c/c++ 
project.
I followed the examples on https://dlang.org/dll-linux.html, 
which works well.

but when I replaced import core.stdc.stdio; with import std.stdioļ¼›
to use writefln() instead of printf(), then things changed.

compiling was still fine. so file still can be loaded.
But writefln() generated a error: "Segmentation fault (core 
dumped)"

I tried to search for solutions everywhere but nothing works.

BTW, in the command "dmd -oflibdll.so dll.o -shared 
-defaultlib=libphobos2.so 
-L-rpath=/path/to/where/shared/library/is" which path should I 
use for "/path/to/where/shared/library/is"? Tried some possible 
paths, none of them works. I compiled so file without "-L-rpath". 
At least for the examples still works

I am new to dLang. I hope I get help here.

Thanks in advance.


More information about the Digitalmars-d-learn mailing list