简体   繁体   中英

gem install pg on MAC 10.7.5?

This is just another thread about the same question. How to install gem pg. I tried almost all the other threads I have found on stackoverflow and it doesn't work.

I tried installing postgress via brew, and via dmg package. And the outcome is the same error.

Xcode Verion: 4.6
Rails Version: 4.0.0
Ruby Version: ruby-2.0.0-p247:

$ gcc --version
i686-apple-darwin11-llvm-gcc-4.2 (GCC) 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2336.11.00)
Copyright (C) 2007 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

$ gem install pg
Building native extensions.  This could take a while...
ERROR:  Error installing pg:
    ERROR: Failed to build gem native extension.

    /Users/arturo/.rvm/rubies/ruby-2.0.0-p247/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=/Users/arturo/.rvm/rubies/ruby-2.0.0-p247/bin/ruby
    --with-pg
    --without-pg
    --with-pg-config
    --without-pg-config
    --with-pg_config
    --without-pg_config
    --with-pg-dir
    --without-pg-dir
    --with-pg-include
    --without-pg-include=${pg-dir}/include
    --with-pg-lib
    --without-pg-lib=${pg-dir}/
    --with-pqlib
    --without-pqlib
    --with-libpqlib
    --without-libpqlib
    --with-ms/libpqlib
    --without-ms/libpqlib


Gem files will remain installed in /Users/arturo/.rvm/gems/ruby-2.0.0-p247/gems/pg-0.16.0 for inspection.
Results logged to /Users/arturo/.rvm/gems/ruby-2.0.0-p247/gems/pg-0.16.0/ext/gem_make.out

$ cat /Users/arturo/.rvm/gems/ruby-2.0.0-p247/gems/pg-0.16.0/ext/mkmf.log 
find_executable: checking for pg_config... -------------------- yes

--------------------

"/usr/bin/clang -o conftest -I/Users/arturo/.rvm/rubies/ruby-2.0.0-p247/include/ruby-2.0.0/x86_64-darwin11.4.2 -I/Users/arturo/.rvm/rubies/ruby-2.0.0-p247/include/ruby-2.0.0/ruby/backward -I/Users/arturo/.rvm/rubies/ruby-2.0.0-p247/include/ruby-2.0.0 -I. -I/usr/include -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -D_DARWIN_UNLIMITED_SELECT -D_REENTRANT -I/opt/local/include    -O3 -fno-fast-math -ggdb3 -Wall -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Wunused-variable -Wpointer-arith -Wwrite-strings -Wdeclaration-after-statement -Wshorten-64-to-32 -Wimplicit-function-declaration  -fno-common -pipe conftest.c  -L. -L/Users/arturo/.rvm/rubies/ruby-2.0.0-p247/lib -L/usr/lib -L/opt/local/lib -L. -fstack-protector -L/usr/local/lib -L/opt/local/lib      -lruby.2.0.0  -lpthread -ldl -lobjc "
checked program was:
/* begin */
1: #include "ruby.h"
2: 
3: int main(int argc, char **argv)
4: {
5:   return 0;
6: }
/* end */

"/usr/bin/clang -o conftest -I/Users/arturo/.rvm/rubies/ruby-2.0.0-p247/include/ruby-2.0.0/x86_64-darwin11.4.2 -I/Users/arturo/.rvm/rubies/ruby-2.0.0-p247/include/ruby-2.0.0/ruby/backward -I/Users/arturo/.rvm/rubies/ruby-2.0.0-p247/include/ruby-2.0.0 -I. -I/usr/include -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -D_DARWIN_UNLIMITED_SELECT -D_REENTRANT -I/opt/local/include    -O3 -fno-fast-math -ggdb3 -Wall -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Wunused-variable -Wpointer-arith -Wwrite-strings -Wdeclaration-after-statement -Wshorten-64-to-32 -Wimplicit-function-declaration  -fno-common -pipe conftest.c  -L. -L/Users/arturo/.rvm/rubies/ruby-2.0.0-p247/lib -L/usr/lib -L/opt/local/lib -L. -fstack-protector -L/usr/local/lib -L/opt/local/lib      -lruby.2.0.0  -Wl,-rpath,/usr/lib -lpthread -ldl -lobjc "
checked program was:
/* begin */
1: #include "ruby.h"
2: 
3: int main() {return 0;}
/* end */

find_header: checking for libpq-fe.h... -------------------- yes

"/usr/bin/clang -E -I/Users/arturo/.rvm/rubies/ruby-2.0.0-p247/include/ruby-2.0.0/x86_64-darwin11.4.2 -I/Users/arturo/.rvm/rubies/ruby-2.0.0-p247/include/ruby-2.0.0/ruby/backward -I/Users/arturo/.rvm/rubies/ruby-2.0.0-p247/include/ruby-2.0.0 -I. -I/usr/include -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -D_DARWIN_UNLIMITED_SELECT -D_REENTRANT -I/opt/local/include    -O3 -fno-fast-math -ggdb3 -Wall -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Wunused-variable -Wpointer-arith -Wwrite-strings -Wdeclaration-after-statement -Wshorten-64-to-32 -Wimplicit-function-declaration  -fno-common -pipe  conftest.c -o conftest.i"
checked program was:
/* begin */
1: #include "ruby.h"
2: 
3: #include <libpq-fe.h>
/* end */

--------------------

find_header: checking for libpq/libpq-fs.h... -------------------- yes

"/usr/bin/clang -E -I/Users/arturo/.rvm/rubies/ruby-2.0.0-p247/include/ruby-2.0.0/x86_64-darwin11.4.2 -I/Users/arturo/.rvm/rubies/ruby-2.0.0-p247/include/ruby-2.0.0/ruby/backward -I/Users/arturo/.rvm/rubies/ruby-2.0.0-p247/include/ruby-2.0.0 -I. -I/usr/include -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -D_DARWIN_UNLIMITED_SELECT -D_REENTRANT -I/opt/local/include    -O3 -fno-fast-math -ggdb3 -Wall -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Wunused-variable -Wpointer-arith -Wwrite-strings -Wdeclaration-after-statement -Wshorten-64-to-32 -Wimplicit-function-declaration  -fno-common -pipe  conftest.c -o conftest.i"
checked program was:
/* begin */
1: #include "ruby.h"
2: 
3: #include <libpq/libpq-fs.h>
/* end */

--------------------

find_header: checking for pg_config_manual.h... -------------------- yes

"/usr/bin/clang -E -I/Users/arturo/.rvm/rubies/ruby-2.0.0-p247/include/ruby-2.0.0/x86_64-darwin11.4.2 -I/Users/arturo/.rvm/rubies/ruby-2.0.0-p247/include/ruby-2.0.0/ruby/backward -I/Users/arturo/.rvm/rubies/ruby-2.0.0-p247/include/ruby-2.0.0 -I. -I/usr/include -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -D_DARWIN_UNLIMITED_SELECT -D_REENTRANT -I/opt/local/include    -O3 -fno-fast-math -ggdb3 -Wall -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Wunused-variable -Wpointer-arith -Wwrite-strings -Wdeclaration-after-statement -Wshorten-64-to-32 -Wimplicit-function-declaration  -fno-common -pipe  conftest.c -o conftest.i"
checked program was:
/* begin */
1: #include "ruby.h"
2: 
3: #include <pg_config_manual.h>
/* end */

--------------------

have_library: checking for PQconnectdb() in -lpq... -------------------- no

"/usr/bin/clang -o conftest -I/Users/arturo/.rvm/rubies/ruby-2.0.0-p247/include/ruby-2.0.0/x86_64-darwin11.4.2 -I/Users/arturo/.rvm/rubies/ruby-2.0.0-p247/include/ruby-2.0.0/ruby/backward -I/Users/arturo/.rvm/rubies/ruby-2.0.0-p247/include/ruby-2.0.0 -I. -I/usr/include -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -D_DARWIN_UNLIMITED_SELECT -D_REENTRANT -I/opt/local/include    -O3 -fno-fast-math -ggdb3 -Wall -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Wunused-variable -Wpointer-arith -Wwrite-strings -Wdeclaration-after-statement -Wshorten-64-to-32 -Wimplicit-function-declaration  -fno-common -pipe conftest.c  -L. -L/Users/arturo/.rvm/rubies/ruby-2.0.0-p247/lib -L/usr/lib -L/opt/local/lib -L. -fstack-protector -L/usr/local/lib -L/opt/local/lib  -Wl,-rpath,/usr/lib     -lruby.2.0.0 -lpq  -lpthread -ldl -lobjc "
Undefined symbols for architecture x86_64:
  "_CRYPTO_num_locks", referenced from:
      _pqsecure_initialize in libpq.a(fe-secure.o)
  "_CRYPTO_set_id_callback", referenced from:
      _pqsecure_destroy in libpq.a(fe-secure.o)
      _pqsecure_initialize in libpq.a(fe-secure.o)
  "_CRYPTO_set_locking_callback", referenced from:
      _pqsecure_destroy in libpq.a(fe-secure.o)
      _pqsecure_initialize in libpq.a(fe-secure.o)
  "_ENGINE_by_id", referenced from:
      _pqsecure_open_client in libpq.a(fe-secure.o)
  "_ENGINE_finish", referenced from:
      _close_SSL in libpq.a(fe-secure.o)
      _pqsecure_open_client in libpq.a(fe-secure.o)
  "_ENGINE_free", referenced from:
      _close_SSL in libpq.a(fe-secure.o)
      _pqsecure_open_client in libpq.a(fe-secure.o)
  "_ENGINE_init", referenced from:
      _pqsecure_open_client in libpq.a(fe-secure.o)
  "_ENGINE_load_private_key", referenced from:
      _pqsecure_open_client in libpq.a(fe-secure.o)
  "_ERR_get_error", referenced from:
      _SSLerrmessage in libpq.a(fe-secure.o)
  "_ERR_reason_error_string", referenced from:
      _SSLerrmessage in libpq.a(fe-secure.o)
  "_GSS_C_NT_HOSTBASED_SERVICE", referenced from:
      _pg_fe_sendauth in libpq.a(fe-auth.o)
  "_OPENSSL_config", referenced from:
      _pqsecure_initialize in libpq.a(fe-secure.o)
  "_SSL_CTX_ctrl", referenced from:
      _pqsecure_initialize in libpq.a(fe-secure.o)
  "_SSL_CTX_get_cert_store", referenced from:
      _pqsecure_open_client in libpq.a(fe-secure.o)
  "_SSL_CTX_load_verify_locations", referenced from:
      _pqsecure_open_client in libpq.a(fe-secure.o)
  "_SSL_CTX_new", referenced from:
      _pqsecure_initialize in libpq.a(fe-secure.o)
  "_SSL_CTX_use_certificate_chain_file", referenced from:
      _pqsecure_open_client in libpq.a(fe-secure.o)
  "_SSL_check_private_key", referenced from:
      _pqsecure_open_client in libpq.a(fe-secure.o)
  "_SSL_connect", referenced from:
      _pqsecure_open_client in libpq.a(fe-secure.o)
  "_SSL_free", referenced from:
      _close_SSL in libpq.a(fe-secure.o)
  "_SSL_get_error", referenced from:
      _pqsecure_write in libpq.a(fe-secure.o)
      _pqsecure_read in libpq.a(fe-secure.o)
      _pqsecure_open_client in libpq.a(fe-secure.o)
  "_SSL_get_peer_certificate", referenced from:
      _pqsecure_open_client in libpq.a(fe-secure.o)
  "_SSL_library_init", referenced from:
      _pqsecure_initialize in libpq.a(fe-secure.o)
  "_SSL_load_error_strings", referenced from:
      _pqsecure_initialize in libpq.a(fe-secure.o)
  "_SSL_new", referenced from:
      _pqsecure_open_client in libpq.a(fe-secure.o)
  "_SSL_pending", referenced from:
      _pqSocketCheck in libpq.a(fe-misc.o)
  "_SSL_read", referenced from:
      _pqsecure_read in libpq.a(fe-secure.o)
  "_SSL_set_ex_data", referenced from:
      _pqsecure_open_client in libpq.a(fe-secure.o)
  "_SSL_set_fd", referenced from:
      _pqsecure_open_client in libpq.a(fe-secure.o)
  "_SSL_set_verify", referenced from:
      _pqsecure_open_client in libpq.a(fe-secure.o)
  "_SSL_shutdown", referenced from:
      _close_SSL in libpq.a(fe-secure.o)
  "_SSL_use_PrivateKey", referenced from:
      _pqsecure_open_client in libpq.a(fe-secure.o)
  "_SSL_use_PrivateKey_file", referenced from:
      _pqsecure_open_client in libpq.a(fe-secure.o)
  "_SSL_use_certificate_file", referenced from:
      _pqsecure_open_client in libpq.a(fe-secure.o)
  "_SSL_write", referenced from:
      _pqsecure_write in libpq.a(fe-secure.o)
  "_TLSv1_method", referenced from:
      _pqsecure_initialize in libpq.a(fe-secure.o)
  "_X509_NAME_get_text_by_NID", referenced from:
      _pqsecure_open_client in libpq.a(fe-secure.o)
  "_X509_NAME_oneline", referenced from:
      _pqsecure_open_client in libpq.a(fe-secure.o)
  "_X509_STORE_load_locations", referenced from:
      _pqsecure_open_client in libpq.a(fe-secure.o)
  "_X509_STORE_set_flags", referenced from:
      _pqsecure_open_client in libpq.a(fe-secure.o)
  "_X509_free", referenced from:
      _close_SSL in libpq.a(fe-secure.o)
  "_X509_get_subject_name", referenced from:
      _pqsecure_open_client in libpq.a(fe-secure.o)
  "_error_message", referenced from:
      _pg_fe_sendauth in libpq.a(fe-auth.o)
  "_gss_delete_sec_context", referenced from:
      _closePGconn in libpq.a(fe-connect.o)
      _pg_GSS_continue in libpq.a(fe-auth.o)
  "_gss_display_status", referenced from:
      _pg_GSS_error_int in libpq.a(fe-auth.o)
  "_gss_import_name", referenced from:
      _pg_fe_sendauth in libpq.a(fe-auth.o)
  "_gss_init_sec_context", referenced from:
      _pg_GSS_continue in libpq.a(fe-auth.o)
  "_gss_release_buffer", referenced from:
      _closePGconn in libpq.a(fe-connect.o)
      _pg_GSS_error_int in libpq.a(fe-auth.o)
      _pg_GSS_continue in libpq.a(fe-auth.o)
  "_gss_release_name", referenced from:
      _closePGconn in libpq.a(fe-connect.o)
      _pg_GSS_continue in libpq.a(fe-auth.o)
  "_krb5_cc_close", referenced from:
      _pg_fe_sendauth in libpq.a(fe-auth.o)
      _pg_krb5_destroy in libpq.a(fe-auth.o)
  "_krb5_cc_default", referenced from:
      _pg_fe_sendauth in libpq.a(fe-auth.o)
  "_krb5_cc_get_principal", referenced from:
      _pg_fe_sendauth in libpq.a(fe-auth.o)
  "_krb5_free_context", referenced from:
      _pg_fe_sendauth in libpq.a(fe-auth.o)
      _pg_krb5_destroy in libpq.a(fe-auth.o)
  "_krb5_free_error", referenced from:
      _pg_fe_sendauth in libpq.a(fe-auth.o)
  "_krb5_free_principal", referenced from:
      _pg_fe_sendauth in libpq.a(fe-auth.o)
      _pg_krb5_destroy in libpq.a(fe-auth.o)
  "_krb5_free_unparsed_name", referenced from:
      _pg_krb5_destroy in libpq.a(fe-auth.o)
  "_krb5_init_context", referenced from:
      _pg_fe_sendauth in libpq.a(fe-auth.o)
  "_krb5_sendauth", referenced from:
      _pg_fe_sendauth in libpq.a(fe-auth.o)
  "_krb5_sname_to_principal", referenced from:
      _pg_fe_sendauth in libpq.a(fe-auth.o)
  "_krb5_unparse_name", referenced from:
      _pg_fe_sendauth in libpq.a(fe-auth.o)
  "_ldap_count_entries", referenced from:
      _parseServiceFile in libpq.a(fe-connect.o)
  "_ldap_err2string", referenced from:
      _parseServiceFile in libpq.a(fe-connect.o)
  "_ldap_first_entry", referenced from:
      _parseServiceFile in libpq.a(fe-connect.o)
  "_ldap_get_values_len", referenced from:
      _parseServiceFile in libpq.a(fe-connect.o)
  "_ldap_init", referenced from:
      _parseServiceFile in libpq.a(fe-connect.o)
  "_ldap_msgfree", referenced from:
      _parseServiceFile in libpq.a(fe-connect.o)
  "_ldap_result", referenced from:
      _parseServiceFile in libpq.a(fe-connect.o)
  "_ldap_search_st", referenced from:
      _parseServiceFile in libpq.a(fe-connect.o)
  "_ldap_simple_bind", referenced from:
      _parseServiceFile in libpq.a(fe-connect.o)
  "_ldap_unbind", referenced from:
      _parseServiceFile in libpq.a(fe-connect.o)
  "_ldap_value_free_len", referenced from:
      _parseServiceFile in libpq.a(fe-connect.o)
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
checked program was:
/* begin */
 1: #include "ruby.h"
 2: 
 3: #include <libpq-fe.h>
 4: 
 5: /*top*/
 6: extern int t(void);
 7: int t(void) { void ((*volatile p)()); p = (void ((*)()))PQconnectdb; return 0; }
 8: int main(int argc, char **argv)
 9: {
10:   if (argc > 1000000) {
11:     printf("%p", &t);
12:   }
13: 
14:   return 0;
15: }
/* end */

"/usr/bin/clang -o conftest -I/Users/arturo/.rvm/rubies/ruby-2.0.0-p247/include/ruby-2.0.0/x86_64-darwin11.4.2 -I/Users/arturo/.rvm/rubies/ruby-2.0.0-p247/include/ruby-2.0.0/ruby/backward -I/Users/arturo/.rvm/rubies/ruby-2.0.0-p247/include/ruby-2.0.0 -I. -I/usr/include -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -D_DARWIN_UNLIMITED_SELECT -D_REENTRANT -I/opt/local/include    -O3 -fno-fast-math -ggdb3 -Wall -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Wunused-variable -Wpointer-arith -Wwrite-strings -Wdeclaration-after-statement -Wshorten-64-to-32 -Wimplicit-function-declaration  -fno-common -pipe conftest.c  -L. -L/Users/arturo/.rvm/rubies/ruby-2.0.0-p247/lib -L/usr/lib -L/opt/local/lib -L. -fstack-protector -L/usr/local/lib -L/opt/local/lib  -Wl,-rpath,/usr/lib     -lruby.2.0.0 -lpq  -lpthread -ldl -lobjc "
conftest.c:7:27: error: too few arguments to function call, single argument 'conninfo' was not specified
int t(void) { PQconnectdb(); return 0; }
              ~~~~~~~~~~~ ^
/usr/include/libpq-fe.h:234:1: note: 'PQconnectdb' declared here
extern PGconn *PQconnectdb(const char *conninfo);
^
1 error generated.
checked program was:
/* begin */
 1: #include "ruby.h"
 2: 
 3: #include <libpq-fe.h>
 4: 
 5: /*top*/
 6: extern int t(void);
 7: int t(void) { PQconnectdb(); return 0; }
 8: int main(int argc, char **argv)
 9: {
10:   if (argc > 1000000) {
11:     printf("%p", &t);
12:   }
13: 
14:   return 0;
15: }
/* end */

--------------------

have_library: checking for PQconnectdb() in -llibpq... -------------------- no

"/usr/bin/clang -o conftest -I/Users/arturo/.rvm/rubies/ruby-2.0.0-p247/include/ruby-2.0.0/x86_64-darwin11.4.2 -I/Users/arturo/.rvm/rubies/ruby-2.0.0-p247/include/ruby-2.0.0/ruby/backward -I/Users/arturo/.rvm/rubies/ruby-2.0.0-p247/include/ruby-2.0.0 -I. -I/usr/include -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -D_DARWIN_UNLIMITED_SELECT -D_REENTRANT -I/opt/local/include    -O3 -fno-fast-math -ggdb3 -Wall -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Wunused-variable -Wpointer-arith -Wwrite-strings -Wdeclaration-after-statement -Wshorten-64-to-32 -Wimplicit-function-declaration  -fno-common -pipe conftest.c  -L. -L/Users/arturo/.rvm/rubies/ruby-2.0.0-p247/lib -L/usr/lib -L/opt/local/lib -L. -fstack-protector -L/usr/local/lib -L/opt/local/lib  -Wl,-rpath,/usr/lib     -lruby.2.0.0 -llibpq  -lpthread -ldl -lobjc "
ld: library not found for -llibpq
clang: error: linker command failed with exit code 1 (use -v to see invocation)
checked program was:
/* begin */
 1: #include "ruby.h"
 2: 
 3: #include <libpq-fe.h>
 4: 
 5: /*top*/
 6: extern int t(void);
 7: int t(void) { void ((*volatile p)()); p = (void ((*)()))PQconnectdb; return 0; }
 8: int main(int argc, char **argv)
 9: {
10:   if (argc > 1000000) {
11:     printf("%p", &t);
12:   }
13: 
14:   return 0;
15: }
/* end */

"/usr/bin/clang -o conftest -I/Users/arturo/.rvm/rubies/ruby-2.0.0-p247/include/ruby-2.0.0/x86_64-darwin11.4.2 -I/Users/arturo/.rvm/rubies/ruby-2.0.0-p247/include/ruby-2.0.0/ruby/backward -I/Users/arturo/.rvm/rubies/ruby-2.0.0-p247/include/ruby-2.0.0 -I. -I/usr/include -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -D_DARWIN_UNLIMITED_SELECT -D_REENTRANT -I/opt/local/include    -O3 -fno-fast-math -ggdb3 -Wall -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Wunused-variable -Wpointer-arith -Wwrite-strings -Wdeclaration-after-statement -Wshorten-64-to-32 -Wimplicit-function-declaration  -fno-common -pipe conftest.c  -L. -L/Users/arturo/.rvm/rubies/ruby-2.0.0-p247/lib -L/usr/lib -L/opt/local/lib -L. -fstack-protector -L/usr/local/lib -L/opt/local/lib  -Wl,-rpath,/usr/lib     -lruby.2.0.0 -llibpq  -lpthread -ldl -lobjc "
conftest.c:7:27: error: too few arguments to function call, single argument 'conninfo' was not specified
int t(void) { PQconnectdb(); return 0; }
              ~~~~~~~~~~~ ^
/usr/include/libpq-fe.h:234:1: note: 'PQconnectdb' declared here
extern PGconn *PQconnectdb(const char *conninfo);
^
1 error generated.
checked program was:
/* begin */
 1: #include "ruby.h"
 2: 
 3: #include <libpq-fe.h>
 4: 
 5: /*top*/
 6: extern int t(void);
 7: int t(void) { PQconnectdb(); return 0; }
 8: int main(int argc, char **argv)
 9: {
10:   if (argc > 1000000) {
11:     printf("%p", &t);
12:   }
13: 
14:   return 0;
15: }
/* end */

--------------------

have_library: checking for PQconnectdb() in -lms/libpq... -------------------- no

"/usr/bin/clang -o conftest -I/Users/arturo/.rvm/rubies/ruby-2.0.0-p247/include/ruby-2.0.0/x86_64-darwin11.4.2 -I/Users/arturo/.rvm/rubies/ruby-2.0.0-p247/include/ruby-2.0.0/ruby/backward -I/Users/arturo/.rvm/rubies/ruby-2.0.0-p247/include/ruby-2.0.0 -I. -I/usr/include -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -D_DARWIN_UNLIMITED_SELECT -D_REENTRANT -I/opt/local/include    -O3 -fno-fast-math -ggdb3 -Wall -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Wunused-variable -Wpointer-arith -Wwrite-strings -Wdeclaration-after-statement -Wshorten-64-to-32 -Wimplicit-function-declaration  -fno-common -pipe conftest.c  -L. -L/Users/arturo/.rvm/rubies/ruby-2.0.0-p247/lib -L/usr/lib -L/opt/local/lib -L. -fstack-protector -L/usr/local/lib -L/opt/local/lib  -Wl,-rpath,/usr/lib     -lruby.2.0.0 -lms/libpq  -lpthread -ldl -lobjc "
ld: library not found for -lms/libpq
clang: error: linker command failed with exit code 1 (use -v to see invocation)
checked program was:
/* begin */
 1: #include "ruby.h"
 2: 
 3: #include <libpq-fe.h>
 4: 
 5: /*top*/
 6: extern int t(void);
 7: int t(void) { void ((*volatile p)()); p = (void ((*)()))PQconnectdb; return 0; }
 8: int main(int argc, char **argv)
 9: {
10:   if (argc > 1000000) {
11:     printf("%p", &t);
12:   }
13: 
14:   return 0;
15: }
/* end */

"/usr/bin/clang -o conftest -I/Users/arturo/.rvm/rubies/ruby-2.0.0-p247/include/ruby-2.0.0/x86_64-darwin11.4.2 -I/Users/arturo/.rvm/rubies/ruby-2.0.0-p247/include/ruby-2.0.0/ruby/backward -I/Users/arturo/.rvm/rubies/ruby-2.0.0-p247/include/ruby-2.0.0 -I. -I/usr/include -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -D_DARWIN_UNLIMITED_SELECT -D_REENTRANT -I/opt/local/include    -O3 -fno-fast-math -ggdb3 -Wall -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Wunused-variable -Wpointer-arith -Wwrite-strings -Wdeclaration-after-statement -Wshorten-64-to-32 -Wimplicit-function-declaration  -fno-common -pipe conftest.c  -L. -L/Users/arturo/.rvm/rubies/ruby-2.0.0-p247/lib -L/usr/lib -L/opt/local/lib -L. -fstack-protector -L/usr/local/lib -L/opt/local/lib  -Wl,-rpath,/usr/lib     -lruby.2.0.0 -lms/libpq  -lpthread -ldl -lobjc "
conftest.c:7:27: error: too few arguments to function call, single argument 'conninfo' was not specified
int t(void) { PQconnectdb(); return 0; }
              ~~~~~~~~~~~ ^
/usr/include/libpq-fe.h:234:1: note: 'PQconnectdb' declared here
extern PGconn *PQconnectdb(const char *conninfo);
^
1 error generated.
checked program was:
/* begin */
 1: #include "ruby.h"
 2: 
 3: #include <libpq-fe.h>
 4: 
 5: /*top*/
 6: extern int t(void);
 7: int t(void) { PQconnectdb(); return 0; }
 8: int main(int argc, char **argv)
 9: {
10:   if (argc > 1000000) {
11:     printf("%p", &t);
12:   }
13: 
14:   return 0;
15: }
/* end */

--------------------

Thanks in advance

SOLUTION The following solution worked for the mysql and postgresql gems on mac.

  1. Make sure xcode + commmand line tools are installed.

  2. In my case I removed mysql and postgresql previous installations. Also I removed rvm, and its ruby versions. (DO NOT DELETE RUBY THAT COMES WITH MAC)

  3. Uninstall brew if it is installed.

  4. Install brew again.

  5. Run $ brew doctor

  6. Fix all warnings from brew doctor.

  7. Run: brew install postgresql

  8. Run: brew install mysql

  9. Install rvm

  10. Run rvm requirements and fix any issues.

  11. Install ruby via rvm

  12. run gem install 'pg'

  13. run gem install 'mysql2'

And all is good (Y)

You must have PostgreSQL installed on your before you can install the pg gem.

Easiest way to install it is to use homebrew: http://brew.sh/

  1. Make sure you have Xcode installed first.
  2. Run: brew install postgresql
  3. Add to your GemFile: gem 'pg'
  4. Run: bundle install

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM