digitalmars.D - How to create a static build
- mandel (4/4) Nov 06 2007 Hi,
- Steven Schveighoffer (7/11) Nov 06 2007 You could use -static on the link line. If you are using dmd, just copy...
- mandel (5/22) Nov 07 2007 glibc..ok. But what about other libraries like zlib?
- Steven Schveighoffer (11/37) Nov 07 2007 Ah. So you don't care if the binary is static or not, but you want to l...
- Gregor Richards (7/51) Nov 07 2007 The more-reliable but also more-GNU-specific version of this, if anybody...
Hi, I like to know how I can make a static build. I can't get my program binaries to run on other linux systems because some shared libs are missing.
Nov 06 2007
"mandel" wroteHi, I like to know how I can make a static build. I can't get my program binaries to run on other linux systems because some shared libs are missing.You could use -static on the link line. If you are using dmd, just copy the link line it outputs to gcc and add the -static argument. However, I don't recommend using this. I have heard there are problems with statically linking against glibc, and the maintainers say they aren't going to fix it because nobody should be using static linking anymore... -Steve
Nov 06 2007
Steven Schveighoffer Wrote:"mandel" wroteglibc..ok. But what about other libraries like zlib? The issue is that I get error messages like "./main: /usr/lib/libz.so.1: no version information available (required by ./main)" the program get mostly killed after that.Hi, I like to know how I can make a static build. I can't get my program binaries to run on other linux systems because some shared libs are missing.You could use -static on the link line. If you are using dmd, just copy the link line it outputs to gcc and add the -static argument. However, I don't recommend using this. I have heard there are problems with statically linking against glibc, and the maintainers say they aren't going to fix it because nobody should be using static linking anymore... -Steve
Nov 07 2007
"mandel" wroteSteven Schveighoffer Wrote:Ah. So you don't care if the binary is static or not, but you want to link statically against a library? that's easy. Most libraries have two forms on linux, a .so form, and a .a form. To link specifically against the .a form, you have to specify the library file on the command line: gcc .... -lz becomes: gcc .... /usr/lib/libz.a This should do the trick. -Steve"mandel" wroteglibc..ok. But what about other libraries like zlib? The issue is that I get error messages like "./main: /usr/lib/libz.so.1: no version information available (required by ./main)" the program get mostly killed after that.Hi, I like to know how I can make a static build. I can't get my program binaries to run on other linux systems because some shared libs are missing.You could use -static on the link line. If you are using dmd, just copy the link line it outputs to gcc and add the -static argument. However, I don't recommend using this. I have heard there are problems with statically linking against glibc, and the maintainers say they aren't going to fix it because nobody should be using static linking anymore... -Steve
Nov 07 2007
Steven Schveighoffer wrote:"mandel" wroteThe more-reliable but also more-GNU-specific version of this, if anybody cares, is: gcc -Wl,-Bstatic,-lz,-Bdynamic This will work regardless of what path libz is in, but will not work with linkers other than GNU ld. - Gregor RichardsSteven Schveighoffer Wrote:Ah. So you don't care if the binary is static or not, but you want to link statically against a library? that's easy. Most libraries have two forms on linux, a .so form, and a .a form. To link specifically against the .a form, you have to specify the library file on the command line: gcc .... -lz becomes: gcc .... /usr/lib/libz.a This should do the trick. -Steve"mandel" wroteglibc..ok. But what about other libraries like zlib? The issue is that I get error messages like "./main: /usr/lib/libz.so.1: no version information available (required by ./main)" the program get mostly killed after that.Hi, I like to know how I can make a static build. I can't get my program binaries to run on other linux systems because some shared libs are missing.You could use -static on the link line. If you are using dmd, just copy the link line it outputs to gcc and add the -static argument. However, I don't recommend using this. I have heard there are problems with statically linking against glibc, and the maintainers say they aren't going to fix it because nobody should be using static linking anymore... -Steve
Nov 07 2007