gpt4 book ai didi

ruby - gem 在 MAC 10.7.5 上安装 pg?

转载 作者:太空宇宙 更新时间:2023-11-03 18:21:10 28 4
gpt4 key购买 nike

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

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

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 gem。

  1. 确保安装了 xcode + 命令行工具。

  2. 在我的例子中,我删除了之前安装的 mysql 和 postgresql。我还删除了 rvm 及其 ruby​​ 版本。 (不要删除 MAC 自带的 Ruby)

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

  4. 再次安装 brew。

  5. 运行 $ brew doctor

  6. 修复来自 brew doctor 的所有警告。

  7. 运行:brew install postgresql

  8. 运行:brew install mysql

  9. 安装rvm

  10. 运行 rvm 要求并修复所有问题。

  11. 通过rvm安装ruby

  12. 运行 gem install 'pg'

  13. 运行 gem install 'mysql2'

一切都很好(Y)

最佳答案

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

安装它的最简单方法是使用自制软件:http://brew.sh/

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

关于ruby - gem 在 MAC 10.7.5 上安装 pg?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18196054/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com