Hi guys, Does someone know how can I create static binaries using autotools? I have a program that uses several dynamic libraries and I want to distribute it as a single static binary. Everytime I want to distribute it, I do a make (the Makefile is generated from configure), then I delete the binary, and do the last linking step myself, using the static flag. This is quite boring. Does someone know a way to create a 'make static'? Thanks in advance, Davi de Castro Reis
Davi de Castro Reis wrote:
Hi guys,
Does someone know how can I create static binaries using autotools? I have a program that uses several dynamic libraries and I want to distribute it as a single static binary. Everytime I want to distribute it, I do a make (the Makefile is generated from configure), then I delete the binary, and do the last linking step myself, using the static flag. This is quite boring. Does someone know a way to create a 'make static'?
Thanks in advance, Davi de Castro Reis
You should be able to put an entry in your Makefile to do whatever you do to manually make the static binary. Static versions of all the dynamic libraries must exist, of course.
William A. Mahaffey III wrote:
Davi de Castro Reis wrote:
Hi guys,
Does someone know how can I create static binaries using autotools? I have a program that uses several dynamic libraries and I want to distribute it as a single static binary. Everytime I want to distribute it, I do a make (the Makefile is generated from configure), then I delete the binary, and do the last linking step myself, using the static flag. This is quite boring. Does someone know a way to create a 'make static'?
Thanks in advance, Davi de Castro Reis
You should be able to put an entry in your Makefile to do whatever you do to manually make the static binary. Static versions of all the dynamic libraries must exist, of course.
Yes I can do, but it is not simple command line and it depends on a lot of user-specified variables (LDFLAGS, CXXFLAGS, CPPFLAGS, CC), and I do it with several different packages. What I want to know if there is some way that I can tell autoconf or automake to generate this entry in the Makefile for me. Something like a STATIC_PROGRAMS = xxxx or AC_CONFIG_STATIC(). Thanks, Davi de Castro Reis
Davi de Castro Reis wrote:
William A. Mahaffey III wrote:
Davi de Castro Reis wrote:
Hi guys,
Does someone know how can I create static binaries using autotools? I have a program that uses several dynamic libraries and I want to distribute it as a single static binary. Everytime I want to distribute it, I do a make (the Makefile is generated from configure), then I delete the binary, and do the last linking step myself, using the static flag. This is quite boring. Does someone know a way to create a 'make static'?
Thanks in advance, Davi de Castro Reis
You should be able to put an entry in your Makefile to do whatever you do to manually make the static binary. Static versions of all the dynamic libraries must exist, of course.
Yes I can do, but it is not simple command line and it depends on a lot of user-specified variables (LDFLAGS, CXXFLAGS, CPPFLAGS, CC), and I do it with several different packages. What I want to know if there is some way that I can tell autoconf or automake to generate this entry in the Makefile for me. Something like a STATIC_PROGRAMS = xxxx or AC_CONFIG_STATIC().
Thanks, Davi de Castro Reis
I believe the autoconf tools use a Makefile.in or some such as the template to generate a Makefile. Put an entry in that file, just as you would in the actual Makefile, to do whatever you want. The various variables you mention are available within the Makefile execution & you should be able to construct your command(s) using them. You could put several entries, 1 per package if required, etc. I don't know more about your specific case, but I have some code (a CAD/grid-generator) which I maintain on SGI (home), Linux (port) & WIN32 (port), all using the same makefile. I could use autoconf if I wanted, but I don't :-). You should be able to put the various entries in the Makefile.in & get things working. All you would really need is different names for your executables & a different link command to link exe.static (and static versions of all the libraries).
Davi de Castro Reis wrote:
Hi guys,
Does someone know how can I create static binaries using autotools? I have a program that uses several dynamic libraries and I want to distribute it as a single static binary. Everytime I want to distribute it, I do a make (the Makefile is generated from configure), then I delete the binary, and do the last linking step myself, using the static flag. This is quite boring. Does someone know a way to create a 'make static'?
Are you looking for the following? ./configure --enable-shared=yes --enable-shared=no These options are standard if your project is built with libtool support. And it is very hard to build shared libraries without libtool support. If you are frequently rebuilding, you can put AC_DISABLE_SHARED before AC_PROG_LIBTOOL in your configure.ac or configure.in file. I suspect that's what you want. I use the opposite: I try to force shared object builds as the default because C++ doesn't work so well with static libraries. -- JDL
Davi de Castro Reis
Does someone know how can I create static binaries using autotools?
Use libtool and it's a simple --enable-static --disable-shared. But please remember that your application is only really static if *no* function for name resolving (gethostbyname(), getpwnam() etc.) is used. Otherwise you get a semi static program because the name resolving functions reside in the libnss* libraries that are *always* dynamically loaded, even if glibc has been linked in statically. Philipp
participants (4)
-
Davi de Castro Reis
-
John Lamb
-
Philipp Thomas
-
William A. Mahaffey III