Undefined "start" character when connecting a D program via LD

I have the following simple program:

import std.stdio; int main(string[] argv) { writeln("Hello, world!"); return 0; } 

I create it as follows:

 DMD -c -m64 -od/proj/out -w -wi -fPIC -debug \ -g -I/proj/hello -unittest /proj/hello.d LD -L/usr/share/dmd/lib/ -arch x86_64 -execute -macosx_version_min 10.7 \ -pie -lm -lpthread -lphobos2 -o /proj/out/hello_app /proj/out/hello.o 

Compiling works fine, but linking stucks to the following:

 Undefined symbols for architecture x86_64: "start", referenced from: -u command line option (maybe you meant: _D3std9algorithm41__T10startsWithVAyaa6_61203d3d2062TAhTAhZ10startsWithFAhAhZb, _D4core6thread6Thread5startMFZv , _D3std9algorithm91__T10startsWithVAyaa11_62203c20612e74696d6554TAS3std8datetime13PosixTimeZone10TransitionTlZ10startsWithFAS3std8datetime13PosixTimeZone10TransitionlZb , _D3std9algorithm43__T10startsWithVAyaa6_61203d3d2062TAyaTAyaZ10startsWithFAyaAyaZb , _D3std9algorithm41__T10startsWithVAyaa6_61203d3d2062TAxaTaZ10startsWithFAxaaZb , _D3std9algorithm92__T10startsWithVAyaa11_62203c20612e74696d6554TAS3std8datetime13PosixTimeZone10LeapSecondTylZ10startsWithFAS3std8datetime13PosixTimeZone10LeapSecondylZb , _D3std9algorithm92__T10startsWithVAyaa11_62203c20612e74696d6554TAS3std8datetime13PosixTimeZone10TransitionTylZ10startsWithFAS3std8datetime13PosixTimeZone10TransitionylZb ) ld: symbol(s) not found for architecture x86_64 , _D3std9algorithm91__T10startsWithVAyaa11_62203c20612e74696d6554TAS3std8datetime13PosixTimeZone10TransitionTlZ10startsWithFAS3std8datetime13PosixTimeZone10TransitionlZb, _D3std9algorithm43__T10startsWithVAyaa6_61203d3d2062TAyaTAyaZ10startsWithFAyaAyaZb, _D3std9algorithm41__T10startsWithVAyaa6_61203d3d2062TAxaTaZ10startsWithFAxaaZb, _D3std9algorithm92__T10startsWithVAyaa11_62203c20612e74696d6554TAS3std8datetime13PosixTimeZone10LeapSecondTylZ10startsWithFAS3std8datetime13PosixTimeZone10LeapSecondylZb, _D3std9algorithm92__T10startsWithVAyaa11_62203c20612e74696d6554TAS3std8datetime13PosixTimeZone10TransitionTylZ10startsWithFAS3std8datetime13PosixTimeZone10TransitionylZb) Undefined symbols for architecture x86_64: "start", referenced from: -u command line option (maybe you meant: _D3std9algorithm41__T10startsWithVAyaa6_61203d3d2062TAhTAhZ10startsWithFAhAhZb, _D4core6thread6Thread5startMFZv , _D3std9algorithm91__T10startsWithVAyaa11_62203c20612e74696d6554TAS3std8datetime13PosixTimeZone10TransitionTlZ10startsWithFAS3std8datetime13PosixTimeZone10TransitionlZb , _D3std9algorithm43__T10startsWithVAyaa6_61203d3d2062TAyaTAyaZ10startsWithFAyaAyaZb , _D3std9algorithm41__T10startsWithVAyaa6_61203d3d2062TAxaTaZ10startsWithFAxaaZb , _D3std9algorithm92__T10startsWithVAyaa11_62203c20612e74696d6554TAS3std8datetime13PosixTimeZone10LeapSecondTylZ10startsWithFAS3std8datetime13PosixTimeZone10LeapSecondylZb , _D3std9algorithm92__T10startsWithVAyaa11_62203c20612e74696d6554TAS3std8datetime13PosixTimeZone10TransitionTylZ10startsWithFAS3std8datetime13PosixTimeZone10TransitionylZb ) ld: symbol(s) not found for architecture x86_64 

I think I forgot some additional static link library to set everything up, but what exactly?

I also saw instructions on how to make a separate compilation and link somewhere on the dlang site, but I can not find it.

UPD1: When linking using GCC using gcc -L/usr/share/dmd/lib/ -lphobos2 -lm -lpthread hello.o it works, but I need to use ld .

+7
source share
2 answers

Add -lcrt1.o at the link.

 LD -L/usr/share/dmd/lib/ -arch x86_64 -execute -macosx_version_min 10.7 \ -pie -lm -lpthread -lphobos2 -lcrt1.o -o /proj/out/hello_app /proj/out/hello.o 

[update] Ah, you get it :)

+6
source

Found due to sheer luck!

It should be associated with -lphobos2 -lm -lpthread and -lcrt1.o - then all the links work fine.

+1
source

All Articles