title: pg gem fails to install on omnibus Chef installation
body: <p>Ola all the smart people.
  I'm facing a problem which I'm trying to solve but failing. I'm trying to install pg gem on the server which has Omnibus Chef installation on ie <a href="http://www.opscode.com/chef/install/">http://www.opscode.com/chef/install/</a></p>
  
  <p>Basically the problem has been reported already (http://tickets.opscode.com/browse/COOK-1406) but I'm looking for a solution to this if there is any - the workaround suggested to install packages from Opscode Ubuntu repos - but those come with ruby 1.8 - I hope I dont have to continue further why I'm feeling reluctant to do that :)</p>
  
  <p>The error I'm getting when installing the pg gem is:</p>
  
  <pre><code>$ sudo /opt/chef/embedded/bin/gem install pg 
  Building native extensions.  This could take a while...
  ERROR:  Error installing pg:
      ERROR: Failed to build gem native extension.
  
          /opt/chef/embedded/bin/ruby extconf.rb
  checking for pg_config... yes
  Using config values from /usr/bin/pg_config
  checking for libpq-fe.h... yes
  checking for libpq/libpq-fs.h... yes
  checking for pg_config_manual.h... yes
  checking for PQconnectdb() in -lpq... no
  checking for PQconnectdb() in -llibpq... no
  checking for PQconnectdb() in -lms/libpq... no
  Can't find the PostgreSQL client library (libpq)
  *** extconf.rb failed ***
  Could not create Makefile due to some reason, probably lack of
  necessary libraries and/or headers.  Check the mkmf.log file for more
  details.  You may need configuration options.
  
  Provided configuration options:
      --with-opt-dir
      --with-opt-include
      --without-opt-include=${opt-dir}/include
      --with-opt-lib
      --without-opt-lib=${opt-dir}/lib
      --with-make-prog
      --without-make-prog
      --srcdir=.
      --curdir
      --ruby=/opt/chef/embedded/bin/ruby
      --with-pg
      --without-pg
      --with-pg-dir
      --without-pg-dir
      --with-pg-include
      --without-pg-include=${pg-dir}/include
      --with-pg-lib
      --without-pg-lib=${pg-dir}/lib
      --with-pg-config
      --without-pg-config
      --with-pg_config
      --without-pg_config
      --with-pqlib
      --without-pqlib
      --with-libpqlib
      --without-libpqlib
      --with-ms/libpqlib
      --without-ms/libpqlib
  
  
  Gem files will remain installed in /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/pg-0.14.1 for inspection.
  Results logged to /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/pg-0.14.1/ext/gem_make.out
  </code></pre>
  
  <p>Faulting bits in the mkmf.log is as follows:</p>
  
  <pre><code>have_library: checking for PQconnectdb() in -lpq... -------------------- no
  
  "gcc -o conftest -I/opt/chef/embedded/include/ruby-1.9.1/x86_64-linux -I/opt/chef/embedded/include/ruby-1.9.1/ruby/backward -I/opt/chef/embedded/include/ruby-1.9.1 -I. -I/opt/chef/embedded/include    -I/usr/include/postgresql -I/opt/chef/embedded/include -fPIC conftest.c  -L. -L/opt/chef/embedded/lib -Wl,-R/opt/chef/embedded/lib -L/opt/chef/embedded/lib -Wl,-R/opt/chef/embedded/lib -L. -Wl,-rpath,/opt/chef/embedded/lib -L/opt/chef/embedded/lib -rdynamic -Wl,-export-dynamic -L/usr/lib     -Wl,-R -Wl,/opt/chef/embedded/lib -L/opt/chef/embedded/lib -lruby -lpq  -lpthread -lrt -ldl -lcrypt -lm   -lc"
  /usr/lib/libpq.so: undefined reference to `SSL_CTX_use_certificate_chain_file@OPENSSL_1.0.0'
  /usr/lib/libpq.so: undefined reference to `SSL_write@OPENSSL_1.0.0'
  /usr/lib/libpq.so: undefined reference to `SSL_set_fd@OPENSSL_1.0.0'
  /usr/lib/libpq.so: undefined reference to `SSL_use_PrivateKey_file@OPENSSL_1.0.0'
  /usr/lib/libpq.so: undefined reference to `CRYPTO_set_locking_callback@OPENSSL_1.0.0'
  /usr/lib/libpq.so: undefined reference to `X509_NAME_get_text_by_NID@OPENSSL_1.0.0'
  /usr/lib/libpq.so: undefined reference to `SSL_connect@OPENSSL_1.0.0'
  /usr/lib/libpq.so: undefined reference to `ENGINE_init@OPENSSL_1.0.0'
  /usr/lib/libpq.so: undefined reference to `X509_STORE_load_locations@OPENSSL_1.0.0'
  /usr/lib/libpq.so: undefined reference to `SSL_CTX_get_cert_store@OPENSSL_1.0.0'
  /usr/lib/libpq.so: undefined reference to `SSL_free@OPENSSL_1.0.0'
  /usr/lib/libpq.so: undefined reference to `SSL_library_init@OPENSSL_1.0.0'
  /usr/lib/libpq.so: undefined reference to `SSL_CTX_ctrl@OPENSSL_1.0.0'
  /usr/lib/libpq.so: undefined reference to `ERR_get_error@OPENSSL_1.0.0'
  /usr/lib/libpq.so: undefined reference to `SSL_pending@OPENSSL_1.0.0'
  /usr/lib/libpq.so: undefined reference to `ENGINE_free@OPENSSL_1.0.0'
  /usr/lib/libpq.so: undefined reference to `X509_get_subject_name@OPENSSL_1.0.0'
  /usr/lib/libpq.so: undefined reference to `SSL_use_certificate_file@OPENSSL_1.0.0'
  /usr/lib/libpq.so: undefined reference to `SSL_check_private_key@OPENSSL_1.0.0'
  /usr/lib/libpq.so: undefined reference to `SSL_load_error_strings@OPENSSL_1.0.0'
  /usr/lib/libpq.so: undefined reference to `ENGINE_by_id@OPENSSL_1.0.0'
  /usr/lib/libpq.so: undefined reference to `SSL_get_peer_certificate@OPENSSL_1.0.0'
  /usr/lib/libpq.so: undefined reference to `SSL_CTX_new@OPENSSL_1.0.0'
  /usr/lib/libpq.so: undefined reference to `CRYPTO_num_locks@OPENSSL_1.0.0'
  /usr/lib/libpq.so: undefined reference to `ENGINE_load_private_key@OPENSSL_1.0.0'
  /usr/lib/libpq.so: undefined reference to `ENGINE_finish@OPENSSL_1.0.0'
  /usr/lib/libpq.so: undefined reference to `SSL_set_verify@OPENSSL_1.0.0'
  /usr/lib/libpq.so: undefined reference to `X509_free@OPENSSL_1.0.0'
  /usr/lib/libpq.so: undefined reference to `CRYPTO_set_id_callback@OPENSSL_1.0.0'
  /usr/lib/libpq.so: undefined reference to `SSL_get_error@OPENSSL_1.0.0'
  /usr/lib/libpq.so: undefined reference to `SSL_new@OPENSSL_1.0.0'
  /usr/lib/libpq.so: undefined reference to `SSL_shutdown@OPENSSL_1.0.0'
  /usr/lib/libpq.so: undefined reference to `SSL_use_PrivateKey@OPENSSL_1.0.0'
  /usr/lib/libpq.so: undefined reference to `TLSv1_method@OPENSSL_1.0.0'
  /usr/lib/libpq.so: undefined reference to `X509_STORE_set_flags@OPENSSL_1.0.0'
  /usr/lib/libpq.so: undefined reference to `SSL_read@OPENSSL_1.0.0'
  /usr/lib/libpq.so: undefined reference to `OPENSSL_config@OPENSSL_1.0.0'
  /usr/lib/libpq.so: undefined reference to `SSL_CTX_load_verify_locations@OPENSSL_1.0.0'
  /usr/lib/libpq.so: undefined reference to `ERR_reason_error_string@OPENSSL_1.0.0'
  /usr/lib/libpq.so: undefined reference to `SSL_set_ex_data@OPENSSL_1.0.0'
  collect2: ld returned 1 exit status
  checked program was:
  /* begin */
  1: #include "ruby.h"
  2: 
  3: #include &lt;libpq-fe.h&gt;
  4: 
  5: /*top*/
  6: int main() {return 0;}
  7: int t() { void ((*volatile p)()); p = (void ((*)()))PQconnectdb; return 0; }
  /* end */
  
  "gcc -o conftest -I/opt/chef/embedded/include/ruby-1.9.1/x86_64-linux -I/opt/chef/embedded/include/ruby-1.9.1/ruby/backward -I/opt/chef/embedded/include/ruby-1.9.1 -I. -I/opt/chef/embedded/include    -I/usr/include/postgresql -I/opt/chef/embedded/include -fPIC conftest.c  -L. -L/opt/chef/embedded/lib -Wl,-R/opt/chef/embedded/lib -L/opt/chef/embedded/lib -Wl,-R/opt/chef/embedded/lib -L. -Wl,-rpath,/opt/chef/embedded/lib -L/opt/chef/embedded/lib -rdynamic -Wl,-export-dynamic -L/usr/lib     -Wl,-R -Wl,/opt/chef/embedded/lib -L/opt/chef/embedded/lib -lruby -lpq  -lpthread -lrt -ldl -lcrypt -lm   -lc"
  conftest.c: In function ‘t’:
  conftest.c:7:1: error: too few arguments to function ‘PQconnectdb’
  /usr/include/postgresql/libpq-fe.h:243:16: note: declared here
  checked program was:
  /* begin */
  1: #include "ruby.h"
  2: 
  3: #include &lt;libpq-fe.h&gt;
  4: 
  5: /*top*/
  6: int main() {return 0;}
  7: int t() { PQconnectdb(); return 0; }
  /* end */
  
  --------------------
  
  have_library: checking for PQconnectdb() in -llibpq... -------------------- no
  
  "gcc -o conftest -I/opt/chef/embedded/include/ruby-1.9.1/x86_64-linux -I/opt/chef/embedded/include/ruby-1.9.1/ruby/backward -I/opt/chef/embedded/include/ruby-1.9.1 -I. -I/opt/chef/embedded/include    -I/usr/include/postgresql -I/opt/chef/embedded/include -fPIC conftest.c  -L. -L/opt/chef/embedded/lib -Wl,-R/opt/chef/embedded/lib -L/opt/chef/embedded/lib -Wl,-R/opt/chef/embedded/lib -L. -Wl,-rpath,/opt/chef/embedded/lib -L/opt/chef/embedded/lib -rdynamic -Wl,-export-dynamic -L/usr/lib     -Wl,-R -Wl,/opt/chef/embedded/lib -L/opt/chef/embedded/lib -lruby -llibpq  -lpthread -lrt -ldl -lcrypt -lm   -lc"
  /usr/bin/ld: cannot find -llibpq
  collect2: ld returned 1 exit status
  checked program was:
  /* begin */
  1: #include "ruby.h"
  2: 
  3: #include &lt;libpq-fe.h&gt;
  4: 
  5: /*top*/
  6: int main() {return 0;}
  7: int t() { void ((*volatile p)()); p = (void ((*)()))PQconnectdb; return 0; }
  /* end */
  
  "gcc -o conftest -I/opt/chef/embedded/include/ruby-1.9.1/x86_64-linux -I/opt/chef/embedded/include/ruby-1.9.1/ruby/backward -I/opt/chef/embedded/include/ruby-1.9.1 -I. -I/opt/chef/embedded/include    -I/usr/include/postgresql -I/opt/chef/embedded/include -fPIC conftest.c  -L. -L/opt/chef/embedded/lib -Wl,-R/opt/chef/embedded/lib -L/opt/chef/embedded/lib -Wl,-R/opt/chef/embedded/lib -L. -Wl,-rpath,/opt/chef/embedded/lib -L/opt/chef/embedded/lib -rdynamic -Wl,-export-dynamic -L/usr/lib     -Wl,-R -Wl,/opt/chef/embedded/lib -L/opt/chef/embedded/lib -lruby -llibpq  -lpthread -lrt -ldl -lcrypt -lm   -lc"
  conftest.c: In function ‘t’:
  conftest.c:7:1: error: too few arguments to function ‘PQconnectdb’
  /usr/include/postgresql/libpq-fe.h:243:16: note: declared here
  checked program was:
  /* begin */
  1: #include "ruby.h"
  2: 
  3: #include &lt;libpq-fe.h&gt;
  4: 
  5: /*top*/
  6: int main() {return 0;}
  7: int t() { PQconnectdb(); return 0; }
  /* end */
  
  --------------------
  
  have_library: checking for PQconnectdb() in -lms/libpq... -------------------- no
  
  "gcc -o conftest -I/opt/chef/embedded/include/ruby-1.9.1/x86_64-linux -I/opt/chef/embedded/include/ruby-1.9.1/ruby/backward -I/opt/chef/embedded/include/ruby-1.9.1 -I. -I/opt/chef/embedded/include    -I/usr/include/postgresql -I/opt/chef/embedded/include -fPIC conftest.c  -L. -L/opt/chef/embedded/lib -Wl,-R/opt/chef/embedded/lib -L/opt/chef/embedded/lib -Wl,-R/opt/chef/embedded/lib -L. -Wl,-rpath,/opt/chef/embedded/lib -L/opt/chef/embedded/lib -rdynamic -Wl,-export-dynamic -L/usr/lib     -Wl,-R -Wl,/opt/chef/embedded/lib -L/opt/chef/embedded/lib -lruby -lms/libpq  -lpthread -lrt -ldl -lcrypt -lm   -lc"
  /usr/bin/ld: cannot find -lms/libpq
  collect2: ld returned 1 exit status
  checked program was:
  /* begin */
  1: #include "ruby.h"
  2: 
  3: #include &lt;libpq-fe.h&gt;
  4: 
  5: /*top*/
  6: int main() {return 0;}
  7: int t() { void ((*volatile p)()); p = (void ((*)()))PQconnectdb; return 0; }
  /* end */
  
  "gcc -o conftest -I/opt/chef/embedded/include/ruby-1.9.1/x86_64-linux -I/opt/chef/embedded/include/ruby-1.9.1/ruby/backward -I/opt/chef/embedded/include/ruby-1.9.1 -I. -I/opt/chef/embedded/include    -I/usr/include/postgresql -I/opt/chef/embedded/include -fPIC conftest.c  -L. -L/opt/chef/embedded/lib -Wl,-R/opt/chef/embedded/lib -L/opt/chef/embedded/lib -Wl,-R/opt/chef/embedded/lib -L. -Wl,-rpath,/opt/chef/embedded/lib -L/opt/chef/embedded/lib -rdynamic -Wl,-export-dynamic -L/usr/lib     -Wl,-R -Wl,/opt/chef/embedded/lib -L/opt/chef/embedded/lib -lruby -lms/libpq  -lpthread -lrt -ldl -lcrypt -lm   -lc"
  conftest.c: In function ‘t’:
  conftest.c:7:1: error: too few arguments to function ‘PQconnectdb’
  /usr/include/postgresql/libpq-fe.h:243:16: note: declared here
  checked program was:
  /* begin */
  1: #include "ruby.h"
  2: 
  3: #include &lt;libpq-fe.h&gt;
  4: 
  5: /*top*/
  6: int main() {return 0;}
  7: int t() { PQconnectdb(); return 0; }
  /* end */
  
  --------------------
  </code></pre>
  
  <p>I think the problem is that pg gem is linked against a different lib than the one postgresql was built against and the compile fails. I'm just wondering if there is anything I could do to work around this ?
  Any amazing bright minds ? 
  Cheers</p>