How to properly compile DMD 2.053 on OSX?

Jacob Carlborg doob at me.com
Thu Jun 2 23:28:22 PDT 2011


On 2011-06-02 21:33, Dan Sanduleac wrote:
> Binaries are provided for OSX, but when I try to compile it (using a
> Makefile placed in dmd2/ shown below), I get linking errors due to
> libphobos2.a whenever I try to link even a basic D program. The program
> however links correctly if I replace my libphobos2.a with the supplied
> osx/lib/libphobos2.a.
>
> *Linking errors:*
>
> $ dmd test.d
> Undefined symbols:
> "_D3std9exception14ErrnoException7__ClassZ", referenced from:
> _D3std9exception14ErrnoException7__ClassZ$non_lazy_ptr in test.o
> _D3std9exception14ErrnoException7__ClassZ$non_lazy_ptr in
> libphobos2.a(exception_59a_102f.o)
> _D3std9exception14ErrnoException7__ClassZ$non_lazy_ptr in
> libphobos2.a(exception_58e_c6a.o)
> _D3std9exception14ErrnoException7__ClassZ$non_lazy_ptr in
> libphobos2.a(exception_58b_1029.o)
> _D3std9exception14ErrnoException7__ClassZ$non_lazy_ptr in
> libphobos2.a(exception_599_c6c.o)
> _D3std9exception14ErrnoException7__ClassZ$non_lazy_ptr in
> libphobos2.a(exception_597_c6a.o)
> _D3std9exception14ErrnoException7__ClassZ$non_lazy_ptr in
> libphobos2.a(exception_590_c6f.o)
> _D3std9exception14ErrnoException7__ClassZ$non_lazy_ptr in
> libphobos2.a(exception_588_102b.o)
> _D3std9exception14ErrnoException7__ClassZ$non_lazy_ptr in
> libphobos2.a(exception_592_c6c.o)
> _D3std9exception14ErrnoException7__ClassZ$non_lazy_ptr in
> libphobos2.a(exception_594_c75.o)
> _D3std9exception14ErrnoException7__ClassZ$non_lazy_ptr in
> libphobos2.a(exception_58d_c6d.o)
> _D3std9exception14ErrnoException7__ClassZ$non_lazy_ptr in
> libphobos2.a(exception_5a0_c71.o)
> _D3std9exception14ErrnoException7__ClassZ$non_lazy_ptr in
> libphobos2.a(exception_4d3_d4e.o)
> (maybe you meant: _D3std9exception14ErrnoException7__ClassZ$non_lazy_ptr)
> "_D3std8datetime12__ModuleInfoZ", referenced from:
> _D3std4file12__ModuleInfoZ in libphobos2.a(file.o)
> _D3std6random12__ModuleInfoZ in libphobos2.a(random.o)
> "_D3std9exception12__ModuleInfoZ", referenced from:
> _D3std5stdio12__ModuleInfoZ in libphobos2.a(stdio.o)
> _D3std5array12__ModuleInfoZ in libphobos2.a(array.o)
> _D3std4conv12__ModuleInfoZ in libphobos2.a(conv.o)
> _D3std6format12__ModuleInfoZ in libphobos2.a(format.o)
> _D3std6string12__ModuleInfoZ in libphobos2.a(string.o)
> _D3std5range12__ModuleInfoZ in libphobos2.a(range.o)
> _D3std9algorithm12__ModuleInfoZ in libphobos2.a(algorithm.o)
> _D3std3utf12__ModuleInfoZ in libphobos2.a(utf.o)
> _D3std4file12__ModuleInfoZ in libphobos2.a(file.o)
> _D3std8typecons12__ModuleInfoZ in libphobos2.a(typecons.o)
> _D3std10functional12__ModuleInfoZ in libphobos2.a(functional.o)
> _D3std6random12__ModuleInfoZ in libphobos2.a(random.o)
> _D3std9container12__ModuleInfoZ in libphobos2.a(container.o)
> _D3std7process12__ModuleInfoZ in libphobos2.a(process.o)
> _D3std7numeric12__ModuleInfoZ in libphobos2.a(numeric.o)
> "_D3std9exception7bailOutFAyaixAaZv", referenced from:
> _D3std9exception173__T7enforceTbVAyaa73_2f55736572732f64616e73616e64756c6561632f4b6974732f444d442f646d64322f6275696c642f62696e2f2e2e2f2e2e2f7372632f70686f626f732f7374642f666f726d61742e64Vi668Z7enforceFbLAxaZb
> in test.o
> _D3std9exception173__T7enforceTbVAyaa73_2f55736572732f64616e73616e64756c6561632f4b6974732f444d442f646d64322f6275696c642f62696e2f2e2e2f2e2e2f7372632f70686f626f732f7374642f666f726d61742e64Vi802Z7enforceFbLAxaZb
> in test.o
> _D3std9exception49__T7enforceTbVAyaa11_7374642f737464696f2e64Vi886Z7enforceFbLAxaZb
> in libphobos2.a(exception_59c_a71.o)
> _D3std9exception49__T7enforceTbVAyaa11_7374642f737464696f2e64Vi629Z7enforceFbLAxaZb
> in libphobos2.a(exception_596_a6c.o)
> _D3std9exception74__T7enforceTPOS4core4stdc5stdio6_iobufVAyaa11_7374642f737464696f2e64Vi446Z7enforceFPOS4core4stdc5stdio6_iobufLAxaZPOS4core4stdc5stdio6_iobuf
> in libphobos2.a(exception_58f_e23.o)
> _D3std9exception49__T7enforceTbVAyaa11_7374642f737464696f2e64Vi587Z7enforceFbLAxaZb
> in libphobos2.a(exception_593_a6f.o)
> _D3std9exception50__T7enforceTbVAyaa11_7374642f737464696f2e64Vi1113Z7enforceFbLAxaZb
> in libphobos2.a(exception_5a1_a91.o)
> _D3std9exception75__T7enforceTPOS4core4stdc5stdio6_iobufVAyaa11_7374642f737464696f2e64Vi1129Z7enforceFPOS4core4stdc5stdio6_iobufLAxaZPOS4core4stdc5stdio6_iobuf
> in libphobos2.a(exception_5a2_e52.o)
> _D3std9exception50__T7enforceTbVAyaa11_7374642f737464696f2e64Vi1045Z7enforceFbLAxaZb
> in libphobos2.a(exception_59d_a95.o)
> _D3std9exception49__T7enforceTbVAyaa11_7374642f737464696f2e64Vi356Z7enforceFbLAxaZb
> in libphobos2.a(exception_58c_a69.o)
> _D3std9exception44__T7enforceTbVAyaa9_7374642f7574662e64Vi313Z7enforceFbLAxaZb
> in libphobos2.a(exception_71e_98e.o)
> _D3std9exception49__T7enforceTbVAyaa11_7374642f737464696f2e64Vi618Z7enforceFbLAxaZb
> in libphobos2.a(exception_595_a6a.o)
> _D3std9exception49__T7enforceTbVAyaa11_7374642f737464696f2e64Vi871Z7enforceFbLAxaZb
> in libphobos2.a(exception_59b_a6b.o)
> _D3std9exception49__T7enforceTbVAyaa11_7374642f737464696f2e64Vi542Z7enforceFbLAxaZb
> in libphobos2.a(exception_591_a66.o)
> _D3std9exception49__T7enforceTbVAyaa11_7374642f737464696f2e64Vi640Z7enforceFbLAxaZb
> in libphobos2.a(exception_598_a65.o)
> _D3std9exception49__T7enforceTkVAyaa11_7374642f737464696f2e64Vi459Z7enforceFkLAxaZk
> in libphobos2.a(exception_59f_a81.o)
> _D3std9exception53__T7enforceTbVAyaa13_7374642f70726f636573732e64Vi544Z7enforceFbLAxaZb
> in libphobos2.a(exception_4d1_b44.o)
> _D3std9exception53__T7enforceTbVAyaa13_7374642f70726f636573732e64Vi564Z7enforceFbLAxaZb
> in libphobos2.a(exception_4d2_b46.o)
> _D3std9exception54__T7enforceTbVAyaa13_7374642f6e756d657269632e64Vi2268Z7enforceFbLAxaZb
> in libphobos2.a(exception_493_b6d.o)
> _D3std9exception50__T7enforceTbVAyaa11_7374642f72616e67652e64Vi3083Z7enforceFbLAxaZb
> in libphobos2.a(exception_52e_a83.o)
> _D3std9exception50__T7enforceTbVAyaa11_7374642f72616e67652e64Vi3114Z7enforceFbLAxaZb
> in libphobos2.a(exception_52f_a7e.o)
> _D3std9exception50__T7enforceTbVAyaa11_7374642f72616e67652e64Vi2911Z7enforceFbLAxaZb
> in libphobos2.a(exception_52b_a82.o)
> _D3std9exception50__T7enforceTbVAyaa11_7374642f61727261792e64Vi1660Z7enforceFbLAxaZb
> in libphobos2.a(exception_76_a94.o)
> _D3std9exception50__T7enforceTbVAyaa11_7374642f61727261792e64Vi1664Z7enforceFbLAxaZb
> in libphobos2.a(exception_77_a98.o)
> _D3std9exception52__T7enforceTbVAyaa12_7374642f666f726d61742e64Vi1140Z7enforceFbLAxaZb
> in libphobos2.a(exception_3a6_af7.o)
> "_D3std9exception14ErrnoException6__ctorMFAyaAyakZC3std9exception14ErrnoException",
> referenced from:
> _D3std9exception178__T12errnoEnforceTiVAyaa72_2f55736572732f64616e73616e64756c6561632f4b6974732f444d442f646d64322f6275696c642f62696e2f2e2e2f2e2e2f7372632f70686f626f732f7374642f737464696f2e64Vi1147Z12errnoEnforceFiLAyaZi
> in test.o
> _D3std9exception80__T12errnoEnforceTPOS4core4stdc5stdio6_iobufVAyaa11_7374642f737464696f2e64Vi848Z12errnoEnforceFPOS4core4stdc5stdio6_iobufLAyaZPOS4core4stdc5stdio6_iobuf
> in libphobos2.a(exception_59a_102f.o)
> _D3std9exception55__T12errnoEnforceTbVAyaa11_7374642f737464696f2e64Vi423Z12errnoEnforceFbLAyaZb
> in libphobos2.a(exception_58e_c6a.o)
> _D3std9exception80__T12errnoEnforceTPOS4core4stdc5stdio6_iobufVAyaa11_7374642f737464696f2e64Vi338Z12errnoEnforceFPOS4core4stdc5stdio6_iobufLAyaZPOS4core4stdc5stdio6_iobuf
> in libphobos2.a(exception_58b_1029.o)
> _D3std9exception55__T12errnoEnforceTbVAyaa11_7374642f737464696f2e64Vi641Z12errnoEnforceFbLAyaZb
> in libphobos2.a(exception_599_c6c.o)
> _D3std9exception55__T12errnoEnforceTbVAyaa11_7374642f737464696f2e64Vi630Z12errnoEnforceFbLAyaZb
> in libphobos2.a(exception_597_c6a.o)
> _D3std9exception55__T12errnoEnforceTbVAyaa11_7374642f737464696f2e64Vi446Z12errnoEnforceFbLAyaZb
> in libphobos2.a(exception_590_c6f.o)
> _D3std9exception80__T12errnoEnforceTPOS4core4stdc5stdio6_iobufVAyaa11_7374642f737464696f2e64Vi286Z12errnoEnforceFPOS4core4stdc5stdio6_iobufLAyaZPOS4core4stdc5stdio6_iobuf
> in libphobos2.a(exception_588_102b.o)
> _D3std9exception55__T12errnoEnforceTbVAyaa11_7374642f737464696f2e64Vi551Z12errnoEnforceFbLAyaZb
> in libphobos2.a(exception_592_c6c.o)
> _D3std9exception55__T12errnoEnforceTbVAyaa11_7374642f737464696f2e64Vi596Z12errnoEnforceFbLAyaZb
> in libphobos2.a(exception_594_c75.o)
> _D3std9exception55__T12errnoEnforceTbVAyaa11_7374642f737464696f2e64Vi417Z12errnoEnforceFbLAyaZb
> in libphobos2.a(exception_58d_c6d.o)
> _D3std9exception55__T12errnoEnforceTbVAyaa11_7374642f737464696f2e64Vi475Z12errnoEnforceFbLAyaZb
> in libphobos2.a(exception_5a0_c71.o)
> _D3std9exception59__T12errnoEnforceTbVAyaa13_7374642f70726f636573732e64Vi566Z12errnoEnforceFbLAyaZb
> in libphobos2.a(exception_4d3_d4e.o)
> ld: symbol(s) not found
> collect2: ld returned 1 exit status
> --- errorlevel 1
>
>
>
> *Makefile:*
>
> BUILDDIR := build
>
> SRCDIR := src
> TARGETS := dmd druntime phobos
> CONF := osx/bin/dmd.conf
>
>
> all: $(TARGETS)
>
> .PHONY: dmd druntime phobos
>
> dmd: $(BUILDDIR)/bin/dmd
> druntime: $(BUILDDIR)/lib/libdruntime.a
> phobos: $(BUILDDIR)/lib/libphobos2.a
>
> $(BUILDDIR)/bin/dmd:
> mkdir -p $(dir $@)
> make -C$(SRCDIR)/dmd -f osx.mak
> cp $(SRCDIR)/dmd/dmd $@
> cp $(CONF) $(BUILDDIR)/bin/dmd.conf
>
> $(BUILDDIR)/lib/libdruntime.a:
> mkdir -p $(dir $@)
> make -C$(SRCDIR)/druntime -f posix.mak
> cp $(SRCDIR)/druntime/lib/libdruntime.a $@
>
>
> $(BUILDDIR)/lib/libphobos2.a:
> mkdir -p $(dir $@)
> make -C$(SRCDIR)/phobos -f osx.mak
> cp $(SRCDIR)/phobos/generated/posix/release/libphobos2.a $@

You should use posix.mak when you're building Phobos. Don't know why DMD 
2.053 contains individual makefiles for Linux and Mac OS X.

-- 
/Jacob Carlborg


More information about the Digitalmars-d mailing list