{"id":7228,"date":"2014-05-31T23:00:59","date_gmt":"2014-05-31T23:00:59","guid":{"rendered":"https:\/\/unknownerror.org\/index.php\/2014\/05\/31\/gem-install-pg-on-mac-10-7-5-collection-of-common-programming-errors\/"},"modified":"2014-05-31T23:00:59","modified_gmt":"2014-05-31T23:00:59","slug":"gem-install-pg-on-mac-10-7-5-collection-of-common-programming-errors","status":"publish","type":"post","link":"https:\/\/unknownerror.org\/index.php\/2014\/05\/31\/gem-install-pg-on-mac-10-7-5-collection-of-common-programming-errors\/","title":{"rendered":"gem install pg on MAC 10.7.5?-Collection of common programming errors"},"content":{"rendered":"<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/1f7f6bd37c819ca2e3482155282661e2?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nJim Lim<\/p>\n<p>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&#8217;t work.<\/p>\n<p>I tried installing postgress via brew, and via dmg package. And the outcome is the same error.<\/p>\n<pre><code>Xcode Verion: 4.6\nRails Version: 4.0.0\nRuby Version: ruby-2.0.0-p247:\n\n$ gcc --version\ni686-apple-darwin11-llvm-gcc-4.2 (GCC) 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2336.11.00)\nCopyright (C) 2007 Free Software Foundation, Inc.\nThis is free software; see the source for copying conditions.  There is NO\nwarranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n\n$ gem install pg\nBuilding native extensions.  This could take a while...\nERROR:  Error installing pg:\n    ERROR: Failed to build gem native extension.\n\n    \/Users\/arturo\/.rvm\/rubies\/ruby-2.0.0-p247\/bin\/ruby extconf.rb\nchecking for pg_config... yes\nUsing config values from \/usr\/bin\/pg_config\nchecking for libpq-fe.h... yes\nchecking for libpq\/libpq-fs.h... yes\nchecking for pg_config_manual.h... yes\nchecking for PQconnectdb() in -lpq... no\nchecking for PQconnectdb() in -llibpq... no\nchecking for PQconnectdb() in -lms\/libpq... no\nCan't find the PostgreSQL client library (libpq)\n*** extconf.rb failed ***\nCould not create Makefile due to some reason, probably lack of necessary\nlibraries and\/or headers.  Check the mkmf.log file for more details.  You may\nneed configuration options.\n\nProvided configuration options:\n    --with-opt-dir\n    --with-opt-include\n    --without-opt-include=${opt-dir}\/include\n    --with-opt-lib\n    --without-opt-lib=${opt-dir}\/lib\n    --with-make-prog\n    --without-make-prog\n    --srcdir=.\n    --curdir\n    --ruby=\/Users\/arturo\/.rvm\/rubies\/ruby-2.0.0-p247\/bin\/ruby\n    --with-pg\n    --without-pg\n    --with-pg-config\n    --without-pg-config\n    --with-pg_config\n    --without-pg_config\n    --with-pg-dir\n    --without-pg-dir\n    --with-pg-include\n    --without-pg-include=${pg-dir}\/include\n    --with-pg-lib\n    --without-pg-lib=${pg-dir}\/\n    --with-pqlib\n    --without-pqlib\n    --with-libpqlib\n    --without-libpqlib\n    --with-ms\/libpqlib\n    --without-ms\/libpqlib\n\n\nGem files will remain installed in \/Users\/arturo\/.rvm\/gems\/ruby-2.0.0-p247\/gems\/pg-0.16.0 for inspection.\nResults logged to \/Users\/arturo\/.rvm\/gems\/ruby-2.0.0-p247\/gems\/pg-0.16.0\/ext\/gem_make.out\n\n$ cat \/Users\/arturo\/.rvm\/gems\/ruby-2.0.0-p247\/gems\/pg-0.16.0\/ext\/mkmf.log \nfind_executable: checking for pg_config... -------------------- yes\n\n--------------------\n\n\"\/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 \"\nchecked program was:\n\/* begin *\/\n1: #include \"ruby.h\"\n2: \n3: int main(int argc, char **argv)\n4: {\n5:   return 0;\n6: }\n\/* end *\/\n\n\"\/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 \"\nchecked program was:\n\/* begin *\/\n1: #include \"ruby.h\"\n2: \n3: int main() {return 0;}\n\/* end *\/\n\nfind_header: checking for libpq-fe.h... -------------------- yes\n\n\"\/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\"\nchecked program was:\n\/* begin *\/\n1: #include \"ruby.h\"\n2: \n3: #include \n\/* end *\/\n\n--------------------\n\nfind_header: checking for libpq\/libpq-fs.h... -------------------- yes\n\n\"\/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\"\nchecked program was:\n\/* begin *\/\n1: #include \"ruby.h\"\n2: \n3: #include \n\/* end *\/\n\n--------------------\n\nfind_header: checking for pg_config_manual.h... -------------------- yes\n\n\"\/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\"\nchecked program was:\n\/* begin *\/\n1: #include \"ruby.h\"\n2: \n3: #include \n\/* end *\/\n\n--------------------\n\nhave_library: checking for PQconnectdb() in -lpq... -------------------- no\n\n\"\/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 \"\nUndefined symbols for architecture x86_64:\n  \"_CRYPTO_num_locks\", referenced from:\n      _pqsecure_initialize in libpq.a(fe-secure.o)\n  \"_CRYPTO_set_id_callback\", referenced from:\n      _pqsecure_destroy in libpq.a(fe-secure.o)\n      _pqsecure_initialize in libpq.a(fe-secure.o)\n  \"_CRYPTO_set_locking_callback\", referenced from:\n      _pqsecure_destroy in libpq.a(fe-secure.o)\n      _pqsecure_initialize in libpq.a(fe-secure.o)\n  \"_ENGINE_by_id\", referenced from:\n      _pqsecure_open_client in libpq.a(fe-secure.o)\n  \"_ENGINE_finish\", referenced from:\n      _close_SSL in libpq.a(fe-secure.o)\n      _pqsecure_open_client in libpq.a(fe-secure.o)\n  \"_ENGINE_free\", referenced from:\n      _close_SSL in libpq.a(fe-secure.o)\n      _pqsecure_open_client in libpq.a(fe-secure.o)\n  \"_ENGINE_init\", referenced from:\n      _pqsecure_open_client in libpq.a(fe-secure.o)\n  \"_ENGINE_load_private_key\", referenced from:\n      _pqsecure_open_client in libpq.a(fe-secure.o)\n  \"_ERR_get_error\", referenced from:\n      _SSLerrmessage in libpq.a(fe-secure.o)\n  \"_ERR_reason_error_string\", referenced from:\n      _SSLerrmessage in libpq.a(fe-secure.o)\n  \"_GSS_C_NT_HOSTBASED_SERVICE\", referenced from:\n      _pg_fe_sendauth in libpq.a(fe-auth.o)\n  \"_OPENSSL_config\", referenced from:\n      _pqsecure_initialize in libpq.a(fe-secure.o)\n  \"_SSL_CTX_ctrl\", referenced from:\n      _pqsecure_initialize in libpq.a(fe-secure.o)\n  \"_SSL_CTX_get_cert_store\", referenced from:\n      _pqsecure_open_client in libpq.a(fe-secure.o)\n  \"_SSL_CTX_load_verify_locations\", referenced from:\n      _pqsecure_open_client in libpq.a(fe-secure.o)\n  \"_SSL_CTX_new\", referenced from:\n      _pqsecure_initialize in libpq.a(fe-secure.o)\n  \"_SSL_CTX_use_certificate_chain_file\", referenced from:\n      _pqsecure_open_client in libpq.a(fe-secure.o)\n  \"_SSL_check_private_key\", referenced from:\n      _pqsecure_open_client in libpq.a(fe-secure.o)\n  \"_SSL_connect\", referenced from:\n      _pqsecure_open_client in libpq.a(fe-secure.o)\n  \"_SSL_free\", referenced from:\n      _close_SSL in libpq.a(fe-secure.o)\n  \"_SSL_get_error\", referenced from:\n      _pqsecure_write in libpq.a(fe-secure.o)\n      _pqsecure_read in libpq.a(fe-secure.o)\n      _pqsecure_open_client in libpq.a(fe-secure.o)\n  \"_SSL_get_peer_certificate\", referenced from:\n      _pqsecure_open_client in libpq.a(fe-secure.o)\n  \"_SSL_library_init\", referenced from:\n      _pqsecure_initialize in libpq.a(fe-secure.o)\n  \"_SSL_load_error_strings\", referenced from:\n      _pqsecure_initialize in libpq.a(fe-secure.o)\n  \"_SSL_new\", referenced from:\n      _pqsecure_open_client in libpq.a(fe-secure.o)\n  \"_SSL_pending\", referenced from:\n      _pqSocketCheck in libpq.a(fe-misc.o)\n  \"_SSL_read\", referenced from:\n      _pqsecure_read in libpq.a(fe-secure.o)\n  \"_SSL_set_ex_data\", referenced from:\n      _pqsecure_open_client in libpq.a(fe-secure.o)\n  \"_SSL_set_fd\", referenced from:\n      _pqsecure_open_client in libpq.a(fe-secure.o)\n  \"_SSL_set_verify\", referenced from:\n      _pqsecure_open_client in libpq.a(fe-secure.o)\n  \"_SSL_shutdown\", referenced from:\n      _close_SSL in libpq.a(fe-secure.o)\n  \"_SSL_use_PrivateKey\", referenced from:\n      _pqsecure_open_client in libpq.a(fe-secure.o)\n  \"_SSL_use_PrivateKey_file\", referenced from:\n      _pqsecure_open_client in libpq.a(fe-secure.o)\n  \"_SSL_use_certificate_file\", referenced from:\n      _pqsecure_open_client in libpq.a(fe-secure.o)\n  \"_SSL_write\", referenced from:\n      _pqsecure_write in libpq.a(fe-secure.o)\n  \"_TLSv1_method\", referenced from:\n      _pqsecure_initialize in libpq.a(fe-secure.o)\n  \"_X509_NAME_get_text_by_NID\", referenced from:\n      _pqsecure_open_client in libpq.a(fe-secure.o)\n  \"_X509_NAME_oneline\", referenced from:\n      _pqsecure_open_client in libpq.a(fe-secure.o)\n  \"_X509_STORE_load_locations\", referenced from:\n      _pqsecure_open_client in libpq.a(fe-secure.o)\n  \"_X509_STORE_set_flags\", referenced from:\n      _pqsecure_open_client in libpq.a(fe-secure.o)\n  \"_X509_free\", referenced from:\n      _close_SSL in libpq.a(fe-secure.o)\n  \"_X509_get_subject_name\", referenced from:\n      _pqsecure_open_client in libpq.a(fe-secure.o)\n  \"_error_message\", referenced from:\n      _pg_fe_sendauth in libpq.a(fe-auth.o)\n  \"_gss_delete_sec_context\", referenced from:\n      _closePGconn in libpq.a(fe-connect.o)\n      _pg_GSS_continue in libpq.a(fe-auth.o)\n  \"_gss_display_status\", referenced from:\n      _pg_GSS_error_int in libpq.a(fe-auth.o)\n  \"_gss_import_name\", referenced from:\n      _pg_fe_sendauth in libpq.a(fe-auth.o)\n  \"_gss_init_sec_context\", referenced from:\n      _pg_GSS_continue in libpq.a(fe-auth.o)\n  \"_gss_release_buffer\", referenced from:\n      _closePGconn in libpq.a(fe-connect.o)\n      _pg_GSS_error_int in libpq.a(fe-auth.o)\n      _pg_GSS_continue in libpq.a(fe-auth.o)\n  \"_gss_release_name\", referenced from:\n      _closePGconn in libpq.a(fe-connect.o)\n      _pg_GSS_continue in libpq.a(fe-auth.o)\n  \"_krb5_cc_close\", referenced from:\n      _pg_fe_sendauth in libpq.a(fe-auth.o)\n      _pg_krb5_destroy in libpq.a(fe-auth.o)\n  \"_krb5_cc_default\", referenced from:\n      _pg_fe_sendauth in libpq.a(fe-auth.o)\n  \"_krb5_cc_get_principal\", referenced from:\n      _pg_fe_sendauth in libpq.a(fe-auth.o)\n  \"_krb5_free_context\", referenced from:\n      _pg_fe_sendauth in libpq.a(fe-auth.o)\n      _pg_krb5_destroy in libpq.a(fe-auth.o)\n  \"_krb5_free_error\", referenced from:\n      _pg_fe_sendauth in libpq.a(fe-auth.o)\n  \"_krb5_free_principal\", referenced from:\n      _pg_fe_sendauth in libpq.a(fe-auth.o)\n      _pg_krb5_destroy in libpq.a(fe-auth.o)\n  \"_krb5_free_unparsed_name\", referenced from:\n      _pg_krb5_destroy in libpq.a(fe-auth.o)\n  \"_krb5_init_context\", referenced from:\n      _pg_fe_sendauth in libpq.a(fe-auth.o)\n  \"_krb5_sendauth\", referenced from:\n      _pg_fe_sendauth in libpq.a(fe-auth.o)\n  \"_krb5_sname_to_principal\", referenced from:\n      _pg_fe_sendauth in libpq.a(fe-auth.o)\n  \"_krb5_unparse_name\", referenced from:\n      _pg_fe_sendauth in libpq.a(fe-auth.o)\n  \"_ldap_count_entries\", referenced from:\n      _parseServiceFile in libpq.a(fe-connect.o)\n  \"_ldap_err2string\", referenced from:\n      _parseServiceFile in libpq.a(fe-connect.o)\n  \"_ldap_first_entry\", referenced from:\n      _parseServiceFile in libpq.a(fe-connect.o)\n  \"_ldap_get_values_len\", referenced from:\n      _parseServiceFile in libpq.a(fe-connect.o)\n  \"_ldap_init\", referenced from:\n      _parseServiceFile in libpq.a(fe-connect.o)\n  \"_ldap_msgfree\", referenced from:\n      _parseServiceFile in libpq.a(fe-connect.o)\n  \"_ldap_result\", referenced from:\n      _parseServiceFile in libpq.a(fe-connect.o)\n  \"_ldap_search_st\", referenced from:\n      _parseServiceFile in libpq.a(fe-connect.o)\n  \"_ldap_simple_bind\", referenced from:\n      _parseServiceFile in libpq.a(fe-connect.o)\n  \"_ldap_unbind\", referenced from:\n      _parseServiceFile in libpq.a(fe-connect.o)\n  \"_ldap_value_free_len\", referenced from:\n      _parseServiceFile in libpq.a(fe-connect.o)\nld: symbol(s) not found for architecture x86_64\nclang: error: linker command failed with exit code 1 (use -v to see invocation)\nchecked program was:\n\/* begin *\/\n 1: #include \"ruby.h\"\n 2: \n 3: #include \n 4: \n 5: \/*top*\/\n 6: extern int t(void);\n 7: int t(void) { void ((*volatile p)()); p = (void ((*)()))PQconnectdb; return 0; }\n 8: int main(int argc, char **argv)\n 9: {\n10:   if (argc &gt; 1000000) {\n11:     printf(\"%p\", &amp;t);\n12:   }\n13: \n14:   return 0;\n15: }\n\/* end *\/\n\n\"\/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 \"\nconftest.c:7:27: error: too few arguments to function call, single argument 'conninfo' was not specified\nint t(void) { PQconnectdb(); return 0; }\n              ~~~~~~~~~~~ ^\n\/usr\/include\/libpq-fe.h:234:1: note: 'PQconnectdb' declared here\nextern PGconn *PQconnectdb(const char *conninfo);\n^\n1 error generated.\nchecked program was:\n\/* begin *\/\n 1: #include \"ruby.h\"\n 2: \n 3: #include \n 4: \n 5: \/*top*\/\n 6: extern int t(void);\n 7: int t(void) { PQconnectdb(); return 0; }\n 8: int main(int argc, char **argv)\n 9: {\n10:   if (argc &gt; 1000000) {\n11:     printf(\"%p\", &amp;t);\n12:   }\n13: \n14:   return 0;\n15: }\n\/* end *\/\n\n--------------------\n\nhave_library: checking for PQconnectdb() in -llibpq... -------------------- no\n\n\"\/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 \"\nld: library not found for -llibpq\nclang: error: linker command failed with exit code 1 (use -v to see invocation)\nchecked program was:\n\/* begin *\/\n 1: #include \"ruby.h\"\n 2: \n 3: #include \n 4: \n 5: \/*top*\/\n 6: extern int t(void);\n 7: int t(void) { void ((*volatile p)()); p = (void ((*)()))PQconnectdb; return 0; }\n 8: int main(int argc, char **argv)\n 9: {\n10:   if (argc &gt; 1000000) {\n11:     printf(\"%p\", &amp;t);\n12:   }\n13: \n14:   return 0;\n15: }\n\/* end *\/\n\n\"\/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 \"\nconftest.c:7:27: error: too few arguments to function call, single argument 'conninfo' was not specified\nint t(void) { PQconnectdb(); return 0; }\n              ~~~~~~~~~~~ ^\n\/usr\/include\/libpq-fe.h:234:1: note: 'PQconnectdb' declared here\nextern PGconn *PQconnectdb(const char *conninfo);\n^\n1 error generated.\nchecked program was:\n\/* begin *\/\n 1: #include \"ruby.h\"\n 2: \n 3: #include \n 4: \n 5: \/*top*\/\n 6: extern int t(void);\n 7: int t(void) { PQconnectdb(); return 0; }\n 8: int main(int argc, char **argv)\n 9: {\n10:   if (argc &gt; 1000000) {\n11:     printf(\"%p\", &amp;t);\n12:   }\n13: \n14:   return 0;\n15: }\n\/* end *\/\n\n--------------------\n\nhave_library: checking for PQconnectdb() in -lms\/libpq... -------------------- no\n\n\"\/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 \"\nld: library not found for -lms\/libpq\nclang: error: linker command failed with exit code 1 (use -v to see invocation)\nchecked program was:\n\/* begin *\/\n 1: #include \"ruby.h\"\n 2: \n 3: #include \n 4: \n 5: \/*top*\/\n 6: extern int t(void);\n 7: int t(void) { void ((*volatile p)()); p = (void ((*)()))PQconnectdb; return 0; }\n 8: int main(int argc, char **argv)\n 9: {\n10:   if (argc &gt; 1000000) {\n11:     printf(\"%p\", &amp;t);\n12:   }\n13: \n14:   return 0;\n15: }\n\/* end *\/\n\n\"\/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 \"\nconftest.c:7:27: error: too few arguments to function call, single argument 'conninfo' was not specified\nint t(void) { PQconnectdb(); return 0; }\n              ~~~~~~~~~~~ ^\n\/usr\/include\/libpq-fe.h:234:1: note: 'PQconnectdb' declared here\nextern PGconn *PQconnectdb(const char *conninfo);\n^\n1 error generated.\nchecked program was:\n\/* begin *\/\n 1: #include \"ruby.h\"\n 2: \n 3: #include \n 4: \n 5: \/*top*\/\n 6: extern int t(void);\n 7: int t(void) { PQconnectdb(); return 0; }\n 8: int main(int argc, char **argv)\n 9: {\n10:   if (argc &gt; 1000000) {\n11:     printf(\"%p\", &amp;t);\n12:   }\n13: \n14:   return 0;\n15: }\n\/* end *\/\n\n--------------------\n<\/code><\/pre>\n<p>Thanks in advance<\/p>\n<p><strong>SOLUTION<\/strong> The following solution worked for the mysql and postgresql gems on mac.<\/p>\n<ol>\n<li>\n<p>Make sure xcode + commmand line tools are installed.<\/p>\n<\/li>\n<li>\n<p>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)<\/p>\n<\/li>\n<li>\n<p>Uninstall brew if it is installed.<\/p>\n<\/li>\n<li>\n<p>Install brew again.<\/p>\n<\/li>\n<li>\n<p>Run $ brew doctor<\/p>\n<\/li>\n<li>\n<p>Fix all warnings from brew doctor.<\/p>\n<\/li>\n<li>\n<p>Run: brew install postgresql<\/p>\n<\/li>\n<li>\n<p>Run: brew install mysql<\/p>\n<\/li>\n<li>\n<p>Install rvm<\/p>\n<\/li>\n<li>\n<p>Run rvm requirements and fix any issues.<\/p>\n<\/li>\n<li>\n<p>Install ruby via rvm<\/p>\n<\/li>\n<li>\n<p>run gem install &#8216;pg&#8217;<\/p>\n<\/li>\n<li>\n<p>run gem install &#8216;mysql2&#8217;<\/p>\n<\/li>\n<\/ol>\n<p>And all is good (Y)<\/p>\n<\/li>\n","protected":false},"excerpt":{"rendered":"<p>Jim Lim 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&#8217;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 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-7228","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/7228","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/comments?post=7228"}],"version-history":[{"count":0,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/7228\/revisions"}],"wp:attachment":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/media?parent=7228"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/categories?post=7228"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/tags?post=7228"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}