Errors installing pg gem on Snow Leopard 07 Jun, 2010
I tried installing the pg
gem on a fresh OS X Snow Leopard system today, having used the postgres
gem on older systems. The install failed, and I got to dig out why... here it is, in case it helps you too:
The first command line I tried was sudo ARCHFLAGS="-arch x86_64" gem install pg
which failed and said the results would be logged to /Library/Ruby/Gems/1.8/gems/pg-0.9.0/ext/gem_make.out
. Not that file, but in another file called mkmf.log, were lines like:
Undefined symbols: "_krb5_cc_get_principal", referenced from: _pg_fe_sendauth in libpq.a(fe-auth.o) "_ldap_value_free_len", referenced from: _parseServiceInfo in libpq.a(fe-connect.o) _parseServiceInfo in libpq.a(fe-connect.o) _parseServiceInfo in libpq.a(fe-connect.o) "_BIO_free", referenced from: _client_cert_cb in libpq.a(fe-secure.o) _client_cert_cb in libpq.a(fe-secure.o) _client_cert_cb in libpq.a(fe-secure.o) _client_cert_cb in libpq.a(fe-secure.o) "_ldap_result", referenced from: _parseServiceInfo in libpq.a(fe-connect.o) "_SSL_load_error_strings", referenced from: _pqsecure_initialize in libpq.a(fe-secure.o)
Glancing at the missing functions, they were all library functions that were in libssl, libcrypto, libkrb5 and libldap. I was able to reconstruct conftest.c and run the gcc line manually which confirmed adding those would fix the problem, so then I just needed the way to add it so gem would know (since it ignored my CFLAGS and LDFLAGS env vars). The fixed version is...
sudo CONFIGURE_ARGS='--with-cflags="-lssl -lcrypto -lldap -lkrb5"' ARCHFLAGS="-arch x86_64" gem install pg
The last bit I needed for that came from this reference, thanks Fedora packagers. Another side note, if you want to try the long options mentioned in the error messages from gem, make sure you preceed them with a --
, like gem install foo -- --long-opt=foo