Thread overview | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|
|
March 28, 2010 -static and dmd | ||||
---|---|---|---|---|
| ||||
With gcc, you can pass it the -static flag and it will statically link everything. Normally, with dmd (on linux at least), it dynamically links all of the C/C++ libraries that it uses. So, if I run ldd (well, ldd32 technically) on one of my programs I get: linux-gate.so.1 => (0xf7794000) libpthread.so.0 => /lib32/libpthread.so.0 (0xf7756000) libm.so.6 => /lib32/libm.so.6 (0xf7730000) libc.so.6 => /lib32/libc.so.6 (0xf75ea000) /lib32/ld-linux.so.2 (0xf7795000) If it were gcc and -static had been used, you'd get not a dynamic executable I'd like to be able to do the equivalent of -static with dmd so that my dmd- generated binaries don't have to link against any of the C/C++ libraries on my system. Is there a way to do that? I can't see any. Certainly, none of dmd's options appear to give that kind of functionality. So, if there is a way to do it, I'd like to know how. Does anyone here know how? - Jonathan M Davis |
March 28, 2010 Re: -static and dmd | ||||
---|---|---|---|---|
| ||||
Posted in reply to Jonathan M Davis | Jonathan M Davis wrote:
> With gcc, you can pass it the -static flag and it will statically link everything. Normally, with dmd (on linux at least), it dynamically links all of the C/C++ libraries that it uses. So, if I run ldd (well, ldd32 technically) on one of my programs I get:
>
> linux-gate.so.1 => (0xf7794000)
> libpthread.so.0 => /lib32/libpthread.so.0 (0xf7756000)
> libm.so.6 => /lib32/libm.so.6 (0xf7730000)
> libc.so.6 => /lib32/libc.so.6 (0xf75ea000)
> /lib32/ld-linux.so.2 (0xf7795000)
>
> If it were gcc and -static had been used, you'd get
>
> not a dynamic executable
>
> I'd like to be able to do the equivalent of -static with dmd so that my dmd-
> generated binaries don't have to link against any of the C/C++ libraries on my system. Is there a way to do that? I can't see any. Certainly, none of dmd's options appear to give that kind of functionality. So, if there is a way to do it, I'd like to know how. Does anyone here know how?
>
> - Jonathan M Davis
Did you try passing -L-static to DMD?
|
March 28, 2010 Re: -static and dmd | ||||
---|---|---|---|---|
| ||||
Posted in reply to Jonathan M Davis | On 28/03/10 10:28, Jonathan M Davis wrote:
> With gcc, you can pass it the -static flag and it will statically link
> everything. Normally, with dmd (on linux at least), it dynamically links all
> of the C/C++ libraries that it uses. So, if I run ldd (well, ldd32
> technically) on one of my programs I get:
>
> linux-gate.so.1 => (0xf7794000)
> libpthread.so.0 => /lib32/libpthread.so.0 (0xf7756000)
> libm.so.6 => /lib32/libm.so.6 (0xf7730000)
> libc.so.6 => /lib32/libc.so.6 (0xf75ea000)
> /lib32/ld-linux.so.2 (0xf7795000)
>
> If it were gcc and -static had been used, you'd get
>
> not a dynamic executable
>
> I'd like to be able to do the equivalent of -static with dmd so that my dmd-
> generated binaries don't have to link against any of the C/C++ libraries on
> my system. Is there a way to do that? I can't see any. Certainly, none of
> dmd's options appear to give that kind of functionality. So, if there is a
> way to do it, I'd like to know how. Does anyone here know how?
>
> - Jonathan M Davis
I don't think dmd offers a way to do this by default, your best bet would be to add -static to the makefile and see how it goes.
|
March 28, 2010 Re: -static and dmd | ||||
---|---|---|---|---|
| ||||
Posted in reply to Robert Clipsham | On 28/03/10 12:35, Robert Clipsham wrote:
> I don't think dmd offers a way to do this by default, your best bet
> would be to add -static to the makefile and see how it goes.
I just saw Mike's reply, I notice I misread your question, sorry. I'd also try what he said, -L-static should do it.
|
March 28, 2010 Re: -static and dmd | ||||
---|---|---|---|---|
| ||||
Posted in reply to Mike Parker | Mike Parker wrote:
> Jonathan M Davis wrote:
>> With gcc, you can pass it the -static flag and it will statically link everything. Normally, with dmd (on linux at least), it dynamically links all of the C/C++ libraries that it uses. So, if I run ldd (well, ldd32 technically) on one of my programs I get:
>>
>> linux-gate.so.1 => (0xf7794000)
>> libpthread.so.0 => /lib32/libpthread.so.0 (0xf7756000)
>> libm.so.6 => /lib32/libm.so.6 (0xf7730000)
>> libc.so.6 => /lib32/libc.so.6 (0xf75ea000)
>> /lib32/ld-linux.so.2 (0xf7795000)
>>
>> If it were gcc and -static had been used, you'd get
>>
>> not a dynamic executable
>>
>> I'd like to be able to do the equivalent of -static with dmd so that my dmd- generated binaries don't have to link against any of the C/C++ libraries on my system. Is there a way to do that? I can't see any. Certainly, none of dmd's options appear to give that kind of functionality. So, if there is a way to do it, I'd like to know how. Does anyone here know how?
>>
>> - Jonathan M Davis
>
> Did you try passing -L-static to DMD?
Ah, thanks. Unfortunately, it doesn't work on my system at the moment. I get
/usr/bin/ld: cannot find -lgcc_s
However, that's probably more of an issue with my system missing stuff than there being a problem with dmd. It probably has to do with how horrid arch linux is with multilib. Still, it looks like I'm closer than I was. Thanks.
- Jonathan M Davis
|
March 29, 2010 Re: -static and dmd | ||||
---|---|---|---|---|
| ||||
Posted in reply to Jonathan M Davis | Jonathan M Davis wrote:
> With gcc, you can pass it the -static flag and it will statically link everything. Normally, with dmd (on linux at least), it dynamically links all of the C/C++ libraries that it uses. So, if I run ldd (well, ldd32 technically) on one of my programs I get:
>
> linux-gate.so.1 => (0xf7794000)
> libpthread.so.0 => /lib32/libpthread.so.0 (0xf7756000)
> libm.so.6 => /lib32/libm.so.6 (0xf7730000)
> libc.so.6 => /lib32/libc.so.6 (0xf75ea000)
> /lib32/ld-linux.so.2 (0xf7795000)
>
> If it were gcc and -static had been used, you'd get
>
> not a dynamic executable
>
> I'd like to be able to do the equivalent of -static with dmd so that my dmd-
> generated binaries don't have to link against any of the C/C++ libraries on my system. Is there a way to do that? I can't see any. Certainly, none of dmd's options appear to give that kind of functionality. So, if there is a way to do it, I'd like to know how. Does anyone here know how?
>
> - Jonathan M Davis
A friend hit the same problem recently and I was able to achieve it by performing the linking step with gcc.
1) Compile with dmd:
dmd -c deneme.d -ofdeneme.o
2) Link with gcc:
gcc deneme.o -static -o deneme ~/dmd/linux/lib/libphobos2.a -lpthread
Worked with my simple test application.
Ali
|
March 30, 2010 Re: -static and dmd | ||||
---|---|---|---|---|
| ||||
Posted in reply to Ali Çehreli | Ali Çehreli wrote:
> Jonathan M Davis wrote:
>> With gcc, you can pass it the -static flag and it will statically link everything. Normally, with dmd (on linux at least), it dynamically links all of the C/C++ libraries that it uses. So, if I run ldd (well, ldd32 technically) on one of my programs I get:
>>
>> linux-gate.so.1 => (0xf7794000)
>> libpthread.so.0 => /lib32/libpthread.so.0 (0xf7756000)
>> libm.so.6 => /lib32/libm.so.6 (0xf7730000)
>> libc.so.6 => /lib32/libc.so.6 (0xf75ea000)
>> /lib32/ld-linux.so.2 (0xf7795000)
>>
>> If it were gcc and -static had been used, you'd get
>>
>> not a dynamic executable
>>
>> I'd like to be able to do the equivalent of -static with dmd so that my dmd- generated binaries don't have to link against any of the C/C++ libraries on my system. Is there a way to do that? I can't see any. Certainly, none of dmd's options appear to give that kind of functionality. So, if there is a way to do it, I'd like to know how. Does anyone here know how?
>>
>> - Jonathan M Davis
>
> A friend hit the same problem recently and I was able to achieve it by performing the linking step with gcc.
>
> 1) Compile with dmd:
>
> dmd -c deneme.d -ofdeneme.o
>
> 2) Link with gcc:
>
> gcc deneme.o -static -o deneme ~/dmd/linux/lib/libphobos2.a -lpthread
>
> Worked with my simple test application.
>
> Ali
Thanks! That seems to have done the trick. It's a pity that it doesn't appear to be doable with dmd directly though. I should probably create an issue for it on the bug tracker.
- Jonathan M Davis
|
March 30, 2010 Re: -static and dmd | ||||
---|---|---|---|---|
| ||||
Posted in reply to Jonathan M Davis | Jonathan M Davis wrote:
> Mike Parker wrote:
>
>> Jonathan M Davis wrote:
>>> With gcc, you can pass it the -static flag and it will statically link everything. Normally, with dmd (on linux at least), it dynamically links all of the C/C++ libraries that it uses. So, if I run ldd (well, ldd32 technically) on one of my programs I get:
>>>
>>> linux-gate.so.1 => (0xf7794000)
>>> libpthread.so.0 => /lib32/libpthread.so.0 (0xf7756000)
>>> libm.so.6 => /lib32/libm.so.6 (0xf7730000)
>>> libc.so.6 => /lib32/libc.so.6 (0xf75ea000)
>>> /lib32/ld-linux.so.2 (0xf7795000)
>>>
>>> If it were gcc and -static had been used, you'd get
>>>
>>> not a dynamic executable
>>>
>>> I'd like to be able to do the equivalent of -static with dmd so that my dmd- generated binaries don't have to link against any of the C/C++ libraries on my system. Is there a way to do that? I can't see any. Certainly, none of dmd's options appear to give that kind of functionality. So, if there is a way to do it, I'd like to know how. Does anyone here know how?
>>>
>>> - Jonathan M Davis
>>
>> Did you try passing -L-static to DMD?
>
> Ah, thanks. Unfortunately, it doesn't work on my system at the moment. I get
>
> /usr/bin/ld: cannot find -lgcc_s
>
> However, that's probably more of an issue with my system missing stuff than there being a problem with dmd. It probably has to do with how horrid arch linux is with multilib. Still, it looks like I'm closer than I was. Thanks.
>
> - Jonathan M Davis
Well, it's not an arch linux issue. My OpenSuSE box has the same problem. It's like it's looking for gcc_s.a, but there's only a gcc_s.so. C++ programs don't have this problem, though (at least none that I've tried), so I don't know what D's doing which messes it up.
- Jonathan M Davis
|
Copyright © 1999-2021 by the D Language Foundation