MAC安装pg在MAC 10.7.5上?

时间:2013-08-12 20:24:58

标签: ruby postgresql rubygems

这只是关于同一问题的另一个主题。如何安装gem pg。我尝试了几乎所有在stackoverflow上找到的其他线程,但它不起作用。

我尝试通过brew安装postgress,并通过dmg包。结果是同样的错误。

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 */

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

提前致谢

以下解决方案适用于mac上的mysql和postgresql gems。

  1. 确保已安装xcode + commmand行工具。

  2. 在我的情况下,我删除了mysql和postgresql以前的安装。 我也删除了rvm及其ruby版本。 (不要删除与MAC相关的红宝石)

  3. 如果已安装brew,请将其卸载。

  4. 再次安装brew。

  5. 运行$ brew doctor

  6. 修复brew医生的所有警告。

  7. 运行:brew install postgresql

  8. 运行:brew install mysql

  9. 安装rvm

  10. 运行rvm要求并修复任何问题。

  11. 通过rvm

  12. 安装ruby
  13. 运行gem install'pg'

  14. 运行gem install'mysql2'

  15. 一切都很好(Y)

1 个答案:

答案 0 :(得分:3)

在安装pg gem之前,必须先安装PostgreSQL。

最简单的安装方法是使用自制程序:http://brew.sh/

  1. 确保先安装Xcode。
  2. 运行:brew install postgresql
  3. 添加到您的GemFile:gem 'pg'
  4. 运行:bundle install
相关问题