Background
In my experience it can be tricky to compile applications that make use of 3rd party libraries and/or system libraries such as glibc etc. The problem is that in addition to your application being built statically, all these libraries need to provide both a dynamic (.so) version as well as a static version (.a) and some libraries just don’t provide this, at least not easily. So you’re forced to compile everything down the stack of dependencies yourself and this can be tough.
Solution
That being said, here courtesy Rick Vanderzwet’s Blog, is a one way to compile subversion statically:
1 2 3 4 5 6 |
% curl -O wget http://archive.apache.org/dist/subversion/subversion-1.7.8.tar.gz % tar zxvf subversion-1.7.8.tar.gz % cd subversion-1.7.8/ % ./get-deps.sh % ./configure --with-ssl --without-gssapi --without-swig --enable-all-static % make |
Confirm with the following commands:
size of executable?
1 2 |
% ls -lh subversion/svn/svn -rwxrwxr-x 1 saml saml 11M Jan 19 22:09 subversion/svn/svn |
executable runs?
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
% subversion/svn/svn --version svn, version 1.7.8 (r1419691) compiled Jan 19 2013, 22:03:50 Copyright (C) 2012 The Apache Software Foundation. This software consists of contributions made by many people; see the NOTICE file for more information. Subversion is open source software, see http://subversion.apache.org/ The following repository access (RA) modules are available: * ra_svn : Module for accessing a repository using the svn network protocol. - with Cyrus SASL authentication - handles 'svn' scheme * ra_local : Module for accessing a repository on local disk. - handles 'file' scheme * ra_serf : Module for accessing a repository via WebDAV protocol using serf. - handles 'http' scheme - handles 'https' scheme |
what does the executable depend on?
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
% ldd subversion/svn/svn linux-vdso.so.1 => (0x00007fffd7463000) libsasl2.so.2 => /usr/lib64/libsasl2.so.2 (0x00000034fc600000) libm.so.6 => /lib64/libm.so.6 (0x00000034e7600000) libssl.so.10 => /usr/lib64/libssl.so.10 (0x0000003210800000) libcrypto.so.10 => /lib64/libcrypto.so.10 (0x000000399a000000) libz.so.1 => /lib64/libz.so.1 (0x00000034e8600000) libmagic.so.1 => /usr/lib64/libmagic.so.1 (0x00000034ef600000) libexpat.so.1 => /lib64/libexpat.so.1 (0x00000034eb200000) libuuid.so.1 => /lib64/libuuid.so.1 (0x00000034eda00000) librt.so.1 => /lib64/librt.so.1 (0x00000034e8a00000) libcrypt.so.1 => /lib64/libcrypt.so.1 (0x00000034f5e00000) libpthread.so.0 => /lib64/libpthread.so.0 (0x00000034e7e00000) libdl.so.2 => /lib64/libdl.so.2 (0x00000034e7a00000) libc.so.6 => /lib64/libc.so.6 (0x00000034e7200000) libresolv.so.2 => /lib64/libresolv.so.2 (0x00000034ea200000) libgssapi_krb5.so.2 => /lib64/libgssapi_krb5.so.2 (0x000000320f800000) libkrb5.so.3 => /lib64/libkrb5.so.3 (0x0000003210000000) libcom_err.so.2 => /lib64/libcom_err.so.2 (0x0000003d3ce00000) libk5crypto.so.3 => /lib64/libk5crypto.so.3 (0x0000003210400000) /lib64/ld-linux-x86-64.so.2 (0x00000034e6e00000) libfreebl3.so => /lib64/libfreebl3.so (0x00000034f6200000) libkrb5support.so.0 => /lib64/libkrb5support.so.0 (0x000000320fc00000) libkeyutils.so.1 => /lib64/libkeyutils.so.1 (0x00000034f3a00000) libselinux.so.1 => /lib64/libselinux.so.1 (0x00000034e8e00000) |
This last bit shows that this executable is still dependent on several dynamic libraries but it’s much less than a typical dynamically built subversion!
References
links
NOTE: For further details regarding my one-liner blog posts, check out my one-liner style guide primer.