digitalmars.D.learn - -static and dmd
- Jonathan M Davis (17/17) Mar 28 2010 With gcc, you can pass it the -static flag and it will statically link
- Mike Parker (2/24) Mar 28 2010 Did you try passing -L-static to DMD?
- Jonathan M Davis (7/33) Mar 28 2010 Ah, thanks. Unfortunately, it doesn't work on my system at the moment. I...
- Jonathan M Davis (6/46) Mar 29 2010 Well, it's not an arch linux issue. My OpenSuSE box has the same problem...
- Robert Clipsham (3/20) Mar 28 2010 I don't think dmd offers a way to do this by default, your best bet
- Robert Clipsham (3/5) Mar 28 2010 I just saw Mike's reply, I notice I misread your question, sorry. I'd
- =?UTF-8?B?QWxpIMOHZWhyZWxp?= (9/31) Mar 29 2010 A friend hit the same problem recently and I was able to achieve it by
- Jonathan M Davis (5/44) Mar 29 2010 Thanks! That seems to have done the trick. It's a pity that it doesn't
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
Mar 28 2010
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 DavisDid you try passing -L-static to DMD?
Mar 28 2010
Mike Parker wrote:Jonathan M Davis wrote: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 DavisWith 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 DavisDid you try passing -L-static to DMD?
Mar 28 2010
Jonathan M Davis wrote:Mike Parker wrote: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 DavisJonathan M Davis wrote: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 DavisWith 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 DavisDid you try passing -L-static to DMD?
Mar 29 2010
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 DavisI 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.
Mar 28 2010
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.
Mar 28 2010
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 DavisA 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
Mar 29 2010
Ali Çehreli wrote:Jonathan M Davis wrote: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 DavisWith 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 DavisA 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
Mar 29 2010