How to compile Phobos with other D code to create a shared library?
Steven Schveighoffer
schveiguy at gmail.com
Mon May 31 21:01:19 UTC 2021
On 5/31/21 4:41 PM, data pulverizer wrote:
> On Monday, 31 May 2021 at 20:32:11 UTC, kinke wrote:
>> On Monday, 31 May 2021 at 19:21:52 UTC, data pulverizer wrote:
>>> ldc2 jbasic.d -O3 -link-defaultlib-shared --betterC --boundscheck=off
>>> -nogc -shared -of=jbasic.so
>>
>> The problem is almost certainly `-betterC`, which disables linking
>> against Phobos and druntime.
>
> Thanks - I should have know that one! I've removed the flag but now I'm
> getting the following error when I try to call the function:
>
> ```
> Aborting from src/core/time.d(2131) MonoTimeImpl!(ClockType.normal)
> failed to get the frequency of the system's monotonic clock.
> signal (6): Aborted
> in expression starting at REPL[2]:1
> gsignal at x86_64-linux-gnu/libc.so.6 (unknown line)
> abort at x86_64-linux-gnu/libc.so.6 (unknown line)
> _D4core8internal5abortQgFNbNiNfMAyaMQemZv at /lib64/libphobos2.so.0.90
> (unknown line)
> _D4core4time__T12MonoTimeImplVEQBdQBb9ClockTypei0ZQBj8currTimeFNbNdNiNeZSQCtQCr__TQCpVQCei0ZQCz
> at dmd/current/lib64/libphobos2.so.0.90 (unknown line)
> _D3std6random13bootstrapSeedFNbNiZm at
> dmd/current/lib64/libphobos2.so.0.90 (unknown line)
> _D3std6random__T17unpredictableSeedTmZQwFNbNdNiNeZm at
> dmd/current/lib64/libphobos2.so.0.90 (unknown line)
> _D3std6random17unpredictableSeedFNbNdNiNeZk at
> dmd/current/lib64/libphobos2.so.0.90 (unknown line)
>
> ```
ticksPerSecond is initialized in the runtime just before static
constructors are run. See
https://github.com/dlang/druntime/blob/2d8b28da39e8bc3bc3172c69bb96c35d77f40d2a/src/rt/dmain2.d#L130
Are you calling Runtime.initialize()?
-Steve
More information about the Digitalmars-d-learn
mailing list