linking C++/D static library - what is "crt0.o"?

bitwise via digitalmars-d-ldc digitalmars-d-ldc at
Sun Dec 28 22:28:03 PST 2014

> IIRC passing -static to gcc/clang means 'statically link with C 
> runtime libraries' not 'make a static library'.  To create a 
> static lib you need to create object files with -c and use 'ar' 
> to create the static library.

Ah! That makes sense ;)

I had actually tried ar, but misunderstood the error I was 
getting. After re-checking my usage, it works as expected.

In the mean time, I've continued to work on this problem and 
found that ldc can be used to link as well:

> ldc2 -lib obj/Debug/main.o obj/Debug/native.o 
> -ofbin/Debug/libtest_lib.a
>ldc2  obj/Debug/main.o obj/Debug/native.o 
>-L/usr/lib/libc++.dylib -ofbin/Debug/test_exec

I can't think of any reason to use one over the other, so I'm 
inclined to go with the second option.


More information about the digitalmars-d-ldc mailing list