So I'm trying to (re-)compile Tor 0.2.3.25 (gzipped tarball) on my OS X 10.5.8 system (with GCC 4.0.1) and it's currently dying horribly here:
gcc -g -O2 -D_FORTIFY_SOURCE=2 -fstack-protector-all -Wstack-protector -fwrapv --param ssp-buffer-size=1 -fPIE -Wall -fno-strict-aliasing -Wno-deprecated-declarations -pie -dead_strip -o tor tor_main.o ./libtor.a ../common/libor.a ../common/libor-crypto.a ../common/libor-event.a -lz -levent -lssl -lcrypto
Undefined symbols:
"_EVP_sha256", referenced from:
_crypto_hmac_sha256 in libor-crypto.a(crypto.o)
"_EVP_aes_128_ctr", referenced from:
_aes_new_cipher in libor-crypto.a(aes.o)
"_RSA_generate_key_ex", referenced from:
_crypto_pk_generate_key_with_bits in libor-crypto.a(crypto.o)
"_SHA256", referenced from:
_crypto_digest256 in libor-crypto.a(crypto.o)
"_SHA256_Update", referenced from:
_crypto_digest_add_bytes in libor-crypto.a(crypto.o)
"_SHA256_Final", referenced from:
_crypto_digest_get_digest in libor-crypto.a(crypto.o)
"_SHA256_Init", referenced from:
_crypto_digest256_new in libor-crypto.a(crypto.o)
ld: symbol(s) not found
collect2: ld returned 1 exit status
make[3]: *** [tor] Error 1
make[2]: *** [all-recursive] Error 1
make[1]: *** [all-recursive] Error 1
make: *** [all] Error 2
I'm assuming I'm going to have to tweak (add?) those symbols in crypto.c and aes.c before trying again, but not being much of a C coder I've got no idea what needs to be changed.
In each of those cases we have another common theme:
ironic:common ben$ pwd
/usr/local/src/tor-0.2.3.25/src/common
ironic:common ben$ cat -n crypto.c | grep _EVP_sha256
ironic:common ben$ cat -n crypto.c | grep EVP_sha256
1630 HMAC(EVP_sha256(), key, (int)key_len, (unsigned char*)msg, (int)msg_len,
ironic:common ben$ cat -n aes.c | grep _EVP_aes_128_ctr
ironic:common ben$ cat -n aes.c | grep EVP_aes_128_ctr
99 EVP_EncryptInit(&cipher->evp, EVP_aes_128_ctr(),
411 /* In openssl 1.0.0, there's an if'd out EVP_aes_128_ctr in evp.h. If
ironic:common ben$ cat -n crypto.c | grep _RSA_generate_key_ex
ironic:common ben$ cat -n crypto.c | grep RSA_generate_key_ex
459 if (RSA_generate_key_ex(r, bits, e, NULL) == -1)
ironic:common ben$
The same check for "_SHA256" falls over because of the existence of DIGEST_SHA256 in crypto.c, but you get the idea.
Now this has compiled before, but recently I did attempt updating OpenSSL (actually I installed it to /usr/local/bin instead of OS X's default of /usr/bin), but I'm not certain that's related in some way to the current failure to compile. It's possible, but it's equally possible that the /usr/local installation would be ignored entirely in favour of the ancient system default in /usr/bin.
If anyone has encountered this before or has a solution, I'd greatly appreciate it. I'm willing to try fixes which involve patching or modifying the source files (e.g. adding C headers), as long as it isn't modifying the crypto itself.
EVP_sha256
should be provided bylibcrypto.dylib
, which is a part ofopenSSL
. What did you use for building openssl? brew? macports? or rolled by hand?-L/usr/local/lib
in that link path, so it's trying to use the built-in openSSL. I'd try pointing at the/usr/local
openSSL, as I've seen reports of build issues on10.5
because of issues with the built-in version. Try./configure --with-openssl-dir=/usr/local
sha256
, which explains the link error. You really do need to link to the copy you built in/usr/local
then