Whether it is possible to produce PURELY statically linked program in D , just like C++

Jacob Carlborg doob at me.com
Thu Sep 13 04:12:40 PDT 2012


On 2012-09-13 11:26, deeproot wrote:

> Now, when i compile with -static flag to gdc then i get following
> warnings
>       $ gdc -static hello.d
>
> /usr/lib/gcc/i686-linux-gnu/4.6/libgphobos2.a(path.o): In
> function
> `_D3std4path11expandTildeFAyaZAya18expandFromDatabaseFAyaZAya':
> (.text+0x335): warning: Using 'getpwnam_r' in statically linked
> applications requires at runtime the shared libraries from the
> glibc version used for linking
> /usr/lib/gcc/i686-linux-gnu/4.6/libgphobos2.a(stdio.o): In
> function `_D3std5stdio11openNetworkFAyatZS3std5stdio4File':
> (.text+0x3d35): warning: Using 'gethostbyname' in statically
> linked applications requires at runtime the shared libraries from
> the glibc version used for linking
>
> There is no reason that my just dead simple hello world program
> should be linked with getpwnam_r and gethostbyname
> ========
> in the same way, dmd compiler produced executable also is
> dynamically linked  only.
> Now, my question is that, whether like C/C++ i can actually get a
> helloworld (that no complex dependencies) program FULLY
> statically linked in D.

I don't know about Linux but on Mac OS X a D application compiled with 
DMD has only one dependency, libSystem.B.dylib, which is the same as for 
a standard C application.

-- 
/Jacob Carlborg


More information about the Digitalmars-d mailing list