Shared library loading and static constructor
Sobaya
sobaya007 at gmail.com
Sat Mar 23 15:58:07 UTC 2019
On Saturday, 23 March 2019 at 09:37:16 UTC, Andre Pany wrote:
> On Friday, 22 March 2019 at 17:52:34 UTC, Sobaya wrote:
>> On Friday, 22 March 2019 at 11:00:32 UTC, Andre Pany wrote:
>>> On Friday, 22 March 2019 at 10:51:58 UTC, Sobaya wrote:
>>>> [...]
>>>
>>> As far as I know different to windows, linus will not search
>>> current working directory for a.so. if this is the issue
>>> here, you have different possibilities. You could determine
>>> the current working directory and use std.path: buildPath to
>>> create an absolute path to a.so.
>>> This path you can then use for Runtime.loadLibrary.
>>>
>>> Or you can set the environment variable LD_LIBRARY_PATH.
>>>
>>> I do not know what is the correct way on linux.
>>>
>>> Kind regards
>>> Andre
>>
>> This is not a problem of path, I think.
>>
>> Because when I do not write static constructor in b.d, that
>> code works.
>>
>> This problem occurs only when static constructor is used.
>
> Did you noticed this thread?
> https://forum.dlang.org/post/eumnxgxtjrvvkhxpwjug@forum.dlang.org
>
> The author has an example for shared static this and it seems
> it works for him although he has some other issues with gc.
>
> Kind regards
> Andre
I read his code(https://github.com/tchaloupka/dlangsharedlib).
But in his code the static constructor is written directly in
worker.d.
Such code works just fine with me.
What I am saying is that it can not be read when a code importing
(a.d) a code including the static constructor (b.d) is compiled
into shared library.
More information about the Digitalmars-d-learn
mailing list