3

Is there a guide to build static version of Tor from latest source on Ubuntu 13.04?

I'm looking for ldd output: not a dynamic executable

There is main problem that I have remembered, openssl-dev doesn't contain static part, only shared version of libraries.

I have no problems on the OpenBSD, but Ubuntu. Am I must rebuild the whole backend by myself?

4

1 Answer 1

4

Building Tor statically is problematic, at best, and not really (well) supported.

I got configure to run with this minor patch:

--- a/configure.ac
+++ b/configure.ac
@@ -542,7 +542,7 @@ AC_ARG_WITH(ssl-dir,
       fi
   ])

-TOR_SEARCH_LIBRARY(openssl, $tryssldir, [-lssl -lcrypto $TOR_LIB_GDI],
+TOR_SEARCH_LIBRARY(openssl, $tryssldir, [-lssl -lcrypto -lz -ldl $TOR_LIB_GDI],
     [#include <openssl/rand.h>],
     [void RAND_add(const void *buf, int num, double entropy);],
     [RAND_add((void*)0,0,0); exit(0);], [],

And then running autogen.sh again.

This is, of course, some horribly monkey-patching without any concern for The Right Thing, but it made configure with --enable-static-tor --with-libevent-dir=/usr/lib/x86_64-linux-gnu --with-openssl-dir=/usr/lib/x86_64-linux-gnu/ --with-zlib-dir=/usr/lib/x86_64-linux-gnu run through.

The build then fails when trying to link tor-gencert, but it produced a static tor binary:

[git|master] weasel@valiant:~/projects/tor/tor/build-tree$ find -name tor
./src/or/tor                                               
[git|master] weasel@valiant:~/projects/tor/tor/build-tree$ file src/or/tor                                                                                                          
src/or/tor: ELF 64-bit LSB executable, x86-64, version 1 (GNU/Linux), statically linked, for GNU/Linux 2.6.26, BuildID[sha1]=0xc35ac69bf7ed2d7c736daec2df91ef6367cc9e74, not stripped
[git|master] weasel@valiant:~/projects/tor/tor/build-tree$ ldd src/or/tor 
        not a dynamic executable

and lots of warnings during the build:

  CCLD   src/or/tor
/usr/lib/x86_64-linux-gnu//libcrypto.a(dso_dlfcn.o): In function `dlfcn_globallookup':
(.text+0x19): warning: Using 'dlopen' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
src/common/libor.a(util.o): In function `check_private_dir':
util.c:(.text+0x4e83): warning: Using 'getgrgid' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
src/or/libtor.a(connection.o): In function `connection_listener_new':
connection.c:(.text+0x3c76): warning: Using 'getpwnam' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
src/or/libtor.a(control.o): In function `getinfo_helper_misc':
control.c:(.text+0x482b): warning: Using 'getpwuid' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
src/common/libor.a(address.o): In function `tor_addr_lookup':
address.c:(.text+0x9ba): warning: Using 'getaddrinfo' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
/usr/lib/x86_64-linux-gnu/libevent.a(evutil.o): In function `evutil_getaddrinfo_common':
(.text+0x14a7): warning: Using 'getprotobynumber' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking

So, in short: It can be done. Maybe not a good idea.

1
  • Anyway, for flexibility it shall be realized. I'm talking about chrooting and speed, plus mobility. Commented Nov 3, 2013 at 18:43

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .