Undefined Reference calling D from C using static linking

Nicholas Wilson via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Thu Mar 23 05:26:40 PDT 2017


On Thursday, 23 March 2017 at 12:06:14 UTC, data pulverizer wrote:
> On Thursday, 23 March 2017 at 11:32:25 UTC, Nicholas Wilson 
> wrote:
>> On Thursday, 23 March 2017 at 10:49:37 UTC, data pulverizer 
>> wrote:
>>> [...]
>>
>> Those functions are the bounds checking function, the non 
>> unittest assert function, the unittest function an module 
>> initialisation function respectively. dmd -boundscheck=off 
>> -release should get rid of the first two, you didn't compile 
>> with -unittest so I'm not sure why the thord one is there at 
>> all. For _d_dso_registry all i can suggest is see what 
>> -betterC gets you.
>
> I just compiled `dmd -c dcode.d -betterC -boundscheck=off` 
> (-betterC probably makes -boundscheck=off irrelevant but I 
> threw it in as a prayer) I am still getting:
>
> ```
> dcode.o:(.text.d_dso_init[.data.d_dso_rec]+0x22): undefined 
> reference to `_d_dso_registry'
> collect2: error: ld returned 1 exit status
> ```

Getting dmd to do the linking should work.
You may wish to see what mir (github.com/libmir) does to build in 
it's "Better C" mode, so i'm sure it is possible, I just don't 
know the incantations, sorry. Perhaps someone else can help.


More information about the Digitalmars-d-learn mailing list