Installing Pg gem for PostGreSQL 8.4

Discussion in 'Ruby' started by Saeed Bhuta, Feb 26, 2010.

  1. what does this return
    $ pg_config --includedir
     
    Reid Thompson, Mar 2, 2010
    #21
    1. Advertisements

  2. Saeed Bhuta

    Saeed Bhuta Guest

    pg_config --includedir
    /usr/include/postgresql
     
    Saeed Bhuta, Mar 3, 2010
    #22
    1. Advertisements

  3. and
    $ ls /usr/include/postgresql
     
    Reid Thompson, Mar 3, 2010
    #23
  4. actually, make that

    $ ls -lrt /usr/include/postgresql
     
    Reid Thompson, Mar 3, 2010
    #24
  5. Saeed Bhuta

    Saeed Bhuta Guest

    ls -lrt /usr/include/postgresql
    total 172
    -rw-r--r-- 1 root root 20694 2009-09-09 17:49 postgres.h
    -rw-r--r-- 1 root root 790 2009-09-09 17:49 postgres_fe.h
    -rw-r--r-- 1 root root 1837 2009-09-09 17:49 postgres_ext.h
    -rw-r--r-- 1 root root 12805 2009-09-09 17:49 port.h
    -rw-r--r-- 1 root root 349 2009-09-09 17:49 pg_trace.h
    -rw-r--r-- 1 root root 766 2009-09-09 17:49 pg_config_os.h
    -rw-r--r-- 1 root root 7583 2009-09-09 17:49 pg_config_manual.h
    -rw-r--r-- 1 root root 24739 2009-09-09 17:49 pg_config.h
    -rw-r--r-- 1 root root 19646 2009-09-09 17:49 libpq-fe.h
    -rw-r--r-- 1 root root 2270 2009-09-09 17:49 libpq-events.h
    -rw-r--r-- 1 root root 24599 2009-09-09 17:49 c.h
    drwxr-xr-x 2 root root 4096 2010-03-02 10:12 libpq
    drwxr-xr-x 3 root root 4096 2010-03-02 10:12 internal
    drwxr-xr-x 2 root root 4096 2010-03-02 10:12 catalog
    drwxr-xr-x 2 root root 4096 2010-03-02 10:12 utils
    drwxr-xr-x 2 root root 4096 2010-03-02 10:12 nodes
    drwxr-xr-x 2 root root 4096 2010-03-02 10:12 mb
    drwxr-xr-x 3 root root 4096 2010-03-02 10:13 8.4
     
    Saeed Bhuta, Mar 3, 2010
    #25

  6. hmm -- until today, on my box

    $ sudo gem install pg

    resulted in 0.8.0 being installed

    today, it installed 0.9.0.

    try this

    in your gems directory, remove the 0.9.0 directory
    (on my box this is at /usr/lib/ruby/gems/1.8/gems/pg-0.9.0)

    then try the install again

    $ sudo gem install pg
     
    Reid Thompson, Mar 3, 2010
    #26
  7. Saeed Bhuta

    Saeed Bhuta Guest

    Deleted the directory and tried the install again but no luck;
    sudo gem install pg
    Building native extensions. This could take a while...
    ERROR: Error installing pg:
    ERROR: Failed to build gem native extension.

    /usr/bin/ruby1.8 extconf.rb
    checking for pg_config... yes
    checking for libpq-fe.h... yes
    checking for libpq/libpq-fs.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
    --without-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=/usr/bin/ruby1.8
    --with-pg
    --without-pg
    --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}/lib
    --enable-static-build
    --disable-static-build
    --with-pqlib
    --without-pqlib
    --with-libpqlib
    --without-libpqlib
    --with-ms/libpqlib
    --without-ms/libpqlib


    Gem files will remain installed in /var/lib/gems/1.8/gems/pg-0.9.0 for
    inspection.
    Results logged to /var/lib/gems/1.8/gems/pg-0.9.0/ext/gem_make.out
     
    Saeed Bhuta, Mar 3, 2010
    #27
  8. checking for pg_config... yes
    I am having the exact same problem on a fresh install on Snow Leopard
    with Ruby 1.9.1p376 and postgres installed via homebrew. This is the
    last entry from mkmf.log

    gcc -o conftest
    -I/Users/tel/.rvm/rubies/ruby-1.9.1-p376/include/ruby-1.9.1/i386-darwin10.2.0
    -I/Users/tel/.rvm/rubies/ruby-1.9.1-p376/include/ruby-1.9.1/ruby/backward
    -I/Users/tel/.rvm/rubies/ruby-1.9.1-p376/include/ruby-1.9.1 -I.
    -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE
    -I/usr/local/homebrew/Cellar/postgresql/8.4.2/include -O2 -g -Wall
    -Wno-parentheses -pipe -fno-common -arch i386 conftest.c -L.
    -L/Users/tel/.rvm/rubies/ruby-1.9.1-p376/lib -L.
    -L/usr/local/homebrew/Cellar/postgresql/8.4.2/lib -arch i386
    -lruby-static -lms/libpq -lpthread -ldl -lobjc "
    conftest.c: In function ‘t’:
    conftest.c:5: warning: implicit declaration of function ‘PQconnectdb’
    ld: library not found for -lms/libpq
    collect2: ld returned 1 exit status
    checked program was:
    /* begin */
    1: #include "ruby.h"
    2:
    3: /*top*/
    4: int main() {return 0;}
    5: int t() { PQconnectdb(); return 0; }
    /* end */

    Tor Erik
     
    Tor Erik Linnerud, Mar 4, 2010
    #28
  9. Saeed Bhuta

    Luis Lavena Guest

    Can you post the contents of mkmf.log that are located here: /var/lib/
    gems/1.8/gems/pg-0.9.0/ext

    Seems that it finds the headers, the pg_config tool, but It cannot
    link to it, which may be related to 32/64 bits binaries.
     
    Luis Lavena, Mar 4, 2010
    #29
  10. Here is mine

    find_executable: checking for pg_config... -------------------- yes

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

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

    "gcc -o conftest
    -I/Users/tel/.rvm/rubies/ruby-1.9.1-p376/include/ruby-1.9.1/i386-darwin10.2.0
    -I/Users/tel/.rvm/rubies/ruby-1.9.1-p376/include/ruby-1.9.1/ruby/backward
    -I/Users/tel/.rvm/rubies/ruby-1.9.1-p376/include/ruby-1.9.1 -I.
    -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE
    -I/usr/local/homebrew/Cellar/postgresql/8.3.9/include -O2 -g -Wall
    -Wno-parentheses -pipe -fno-common -arch i386 conftest.c -L.
    -L/Users/tel/.rvm/rubies/ruby-1.9.1-p376/lib -L.
    -L/usr/local/homebrew/Cellar/postgresql/8.3.9/lib -arch i386
    -lruby-static -lpthread -ldl -lobjc "
    ld: warning: in
    /Users/tel/.rvm/rubies/ruby-1.9.1-p376/lib/libruby-static.a, file is not
    of required architecture
    checked program was:
    /* begin */
    1: #include "ruby.h"
    2:
    3: int main() {return 0;}
    /* end */

    "gcc -E
    -I/Users/tel/.rvm/rubies/ruby-1.9.1-p376/include/ruby-1.9.1/i386-darwin10.2.0
    -I/Users/tel/.rvm/rubies/ruby-1.9.1-p376/include/ruby-1.9.1/ruby/backward
    -I/Users/tel/.rvm/rubies/ruby-1.9.1-p376/include/ruby-1.9.1 -I.
    -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE
    -I/usr/local/homebrew/Cellar/postgresql/8.3.9/include -O2 -g -Wall
    -Wno-parentheses -pipe -fno-common -arch i386 conftest.c -o conftest.i"
    checked program was:
    /* begin */
    1: #include "ruby.h"
    2:
    3: #include <libpq-fe.h>
    /* end */

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

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

    "gcc -E
    -I/Users/tel/.rvm/rubies/ruby-1.9.1-p376/include/ruby-1.9.1/i386-darwin10.2.0
    -I/Users/tel/.rvm/rubies/ruby-1.9.1-p376/include/ruby-1.9.1/ruby/backward
    -I/Users/tel/.rvm/rubies/ruby-1.9.1-p376/include/ruby-1.9.1 -I.
    -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE
    -I/usr/local/homebrew/Cellar/postgresql/8.3.9/include -O2 -g -Wall
    -Wno-parentheses -pipe -fno-common -arch i386 conftest.c -o conftest.i"
    checked program was:
    /* begin */
    1: #include "ruby.h"
    2:
    3: #include <libpq/libpq-fs.h>
    /* end */

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

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

    "gcc -o conftest
    -I/Users/tel/.rvm/rubies/ruby-1.9.1-p376/include/ruby-1.9.1/i386-darwin10.2.0
    -I/Users/tel/.rvm/rubies/ruby-1.9.1-p376/include/ruby-1.9.1/ruby/backward
    -I/Users/tel/.rvm/rubies/ruby-1.9.1-p376/include/ruby-1.9.1 -I.
    -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE
    -I/usr/local/homebrew/Cellar/postgresql/8.3.9/include -O2 -g -Wall
    -Wno-parentheses -pipe -fno-common -arch i386 conftest.c -L.
    -L/Users/tel/.rvm/rubies/ruby-1.9.1-p376/lib -L.
    -L/usr/local/homebrew/Cellar/postgresql/8.3.9/lib -arch i386
    -lruby-static -lpq -lpthread -ldl -lobjc "
    conftest.c: In function ‘t’:
    conftest.c:5: error: ‘PQconnectdb’ undeclared (first use in this
    function)
    conftest.c:5: error: (Each undeclared identifier is reported only once
    conftest.c:5: error: for each function it appears in.)
    checked program was:
    /* begin */
    1: #include "ruby.h"
    2:
    3: /*top*/
    4: int main() {return 0;}
    5: int t() { void ((*volatile p)()); p = (void ((*)()))PQconnectdb;
    return 0; }
    /* end */

    "gcc -o conftest
    -I/Users/tel/.rvm/rubies/ruby-1.9.1-p376/include/ruby-1.9.1/i386-darwin10.2.0
    -I/Users/tel/.rvm/rubies/ruby-1.9.1-p376/include/ruby-1.9.1/ruby/backward
    -I/Users/tel/.rvm/rubies/ruby-1.9.1-p376/include/ruby-1.9.1 -I.
    -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE
    -I/usr/local/homebrew/Cellar/postgresql/8.3.9/include -O2 -g -Wall
    -Wno-parentheses -pipe -fno-common -arch i386 conftest.c -L.
    -L/Users/tel/.rvm/rubies/ruby-1.9.1-p376/lib -L.
    -L/usr/local/homebrew/Cellar/postgresql/8.3.9/lib -arch i386
    -lruby-static -lpq -lpthread -ldl -lobjc "
    conftest.c: In function ‘t’:
    conftest.c:5: warning: implicit declaration of function ‘PQconnectdb’
    ld: warning: in
    /Users/tel/.rvm/rubies/ruby-1.9.1-p376/lib/libruby-static.a, file is not
    of required architecture
    ld: warning: in
    /usr/local/homebrew/Cellar/postgresql/8.3.9/lib/libpq.dylib, file is not
    of required architecture
    Undefined symbols:
    "_PQconnectdb", referenced from:
    _t in ccQWN7dm.o
    ld: symbol(s) not found
    collect2: ld returned 1 exit status
    checked program was:
    /* begin */
    1: #include "ruby.h"
    2:
    3: /*top*/
    4: int main() {return 0;}
    5: int t() { PQconnectdb(); return 0; }
    /* end */

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

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

    "gcc -o conftest
    -I/Users/tel/.rvm/rubies/ruby-1.9.1-p376/include/ruby-1.9.1/i386-darwin10.2.0
    -I/Users/tel/.rvm/rubies/ruby-1.9.1-p376/include/ruby-1.9.1/ruby/backward
    -I/Users/tel/.rvm/rubies/ruby-1.9.1-p376/include/ruby-1.9.1 -I.
    -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE
    -I/usr/local/homebrew/Cellar/postgresql/8.3.9/include -O2 -g -Wall
    -Wno-parentheses -pipe -fno-common -arch i386 conftest.c -L.
    -L/Users/tel/.rvm/rubies/ruby-1.9.1-p376/lib -L.
    -L/usr/local/homebrew/Cellar/postgresql/8.3.9/lib -arch i386
    -lruby-static -llibpq -lpthread -ldl -lobjc "
    conftest.c: In function ‘t’:
    conftest.c:5: error: ‘PQconnectdb’ undeclared (first use in this
    function)
    conftest.c:5: error: (Each undeclared identifier is reported only once
    conftest.c:5: error: for each function it appears in.)
    checked program was:
    /* begin */
    1: #include "ruby.h"
    2:
    3: /*top*/
    4: int main() {return 0;}
    5: int t() { void ((*volatile p)()); p = (void ((*)()))PQconnectdb;
    return 0; }
    /* end */

    "gcc -o conftest
    -I/Users/tel/.rvm/rubies/ruby-1.9.1-p376/include/ruby-1.9.1/i386-darwin10.2.0
    -I/Users/tel/.rvm/rubies/ruby-1.9.1-p376/include/ruby-1.9.1/ruby/backward
    -I/Users/tel/.rvm/rubies/ruby-1.9.1-p376/include/ruby-1.9.1 -I.
    -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE
    -I/usr/local/homebrew/Cellar/postgresql/8.3.9/include -O2 -g -Wall
    -Wno-parentheses -pipe -fno-common -arch i386 conftest.c -L.
    -L/Users/tel/.rvm/rubies/ruby-1.9.1-p376/lib -L.
    -L/usr/local/homebrew/Cellar/postgresql/8.3.9/lib -arch i386
    -lruby-static -llibpq -lpthread -ldl -lobjc "
    conftest.c: In function ‘t’:
    conftest.c:5: warning: implicit declaration of function ‘PQconnectdb’
    ld: library not found for -llibpq
    collect2: ld returned 1 exit status
    checked program was:
    /* begin */
    1: #include "ruby.h"
    2:
    3: /*top*/
    4: int main() {return 0;}
    5: int t() { PQconnectdb(); return 0; }
    /* end */

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

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

    "gcc -o conftest
    -I/Users/tel/.rvm/rubies/ruby-1.9.1-p376/include/ruby-1.9.1/i386-darwin10.2.0
    -I/Users/tel/.rvm/rubies/ruby-1.9.1-p376/include/ruby-1.9.1/ruby/backward
    -I/Users/tel/.rvm/rubies/ruby-1.9.1-p376/include/ruby-1.9.1 -I.
    -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE
    -I/usr/local/homebrew/Cellar/postgresql/8.3.9/include -O2 -g -Wall
    -Wno-parentheses -pipe -fno-common -arch i386 conftest.c -L.
    -L/Users/tel/.rvm/rubies/ruby-1.9.1-p376/lib -L.
    -L/usr/local/homebrew/Cellar/postgresql/8.3.9/lib -arch i386
    -lruby-static -lms/libpq -lpthread -ldl -lobjc "
    conftest.c: In function ‘t’:
    conftest.c:5: error: ‘PQconnectdb’ undeclared (first use in this
    function)
    conftest.c:5: error: (Each undeclared identifier is reported only once
    conftest.c:5: error: for each function it appears in.)
    checked program was:
    /* begin */
    1: #include "ruby.h"
    2:
    3: /*top*/
    4: int main() {return 0;}
    5: int t() { void ((*volatile p)()); p = (void ((*)()))PQconnectdb;
    return 0; }
    /* end */

    "gcc -o conftest
    -I/Users/tel/.rvm/rubies/ruby-1.9.1-p376/include/ruby-1.9.1/i386-darwin10.2.0
    -I/Users/tel/.rvm/rubies/ruby-1.9.1-p376/include/ruby-1.9.1/ruby/backward
    -I/Users/tel/.rvm/rubies/ruby-1.9.1-p376/include/ruby-1.9.1 -I.
    -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE
    -I/usr/local/homebrew/Cellar/postgresql/8.3.9/include -O2 -g -Wall
    -Wno-parentheses -pipe -fno-common -arch i386 conftest.c -L.
    -L/Users/tel/.rvm/rubies/ruby-1.9.1-p376/lib -L.
    -L/usr/local/homebrew/Cellar/postgresql/8.3.9/lib -arch i386
    -lruby-static -lms/libpq -lpthread -ldl -lobjc "
    conftest.c: In function ‘t’:
    conftest.c:5: warning: implicit declaration of function ‘PQconnectdb’
    ld: library not found for -lms/libpq
    collect2: ld returned 1 exit status
    checked program was:
    /* begin */
    1: #include "ruby.h"
    2:
    3: /*top*/
    4: int main() {return 0;}
    5: int t() { PQconnectdb(); return 0; }
    /* end */
     
    Tor Erik Linnerud, Mar 4, 2010
    #30
  11. what is this supposed to be?
     
    Reid Thompson, Mar 4, 2010
    #31
  12. Saeed Bhuta

    Luis Lavena Guest

    Is testing the locations of the libraries:

    http://bitbucket.org/ged/ruby-pg/src/tip/ext/extconf.rb#cl-103

    If cannot find one, then reports the problem.

    I see that postgres was installed using homebrew, which I'm not
    familiar with the settings it will use to build stuff.

    I would suggest you direct these questions to the developers of pg
    gem, as this issue is quite specific of your combination of elements
    in your environment.

    You can find all the related links here:

    http://rubygems.org/gems/pg

    Apologizes for not being more helpful.
     
    Luis Lavena, Mar 4, 2010
    #32
  13. I assume you're the anonymous creator of this ticket:

    http://bitbucket.org/ged/ruby-pg/issue/24/090-gem-fails-to-build

    as the description looks the same. If you are, you have the ARCHFLAGS
    environment variable set to "-arch i386", which isn't correct for Snow
    Leopard. Try either unsetting ARCHFLAGS, in which case the build system
    should detect the correct setting, or reset it manually to "-arch x86_64".

    If you aren't the creator of that ticket (and you aren't manually
    setting your ARCHFLAGS to the incorrect architecture), please file a bug
    with the output from 'gem install pg' here:

    http://bitbucket.org/ged/ruby-pg/issues/new/

    and attach your mkmf.log in its entirety. Thanks!
     
    Michael Granger, Mar 4, 2010
    #33
  14. I assume you're the anonymous creator of this ticket: That is correct :)
    Doh! Even though the system it completely new, I had copied over my
    bash_profile and it was indeed setting ARCHFLAGS to '-arch i386'. Works
    perfectly after removing it.

    Thanks a lot for the help, much appreciated.

    Tor Erik
     
    Tor Erik Linnerud, Mar 5, 2010
    #34
  15. Saeed Bhuta

    John Miller Guest

    This post was helpful because it helped me to realize that I needed gcc
    installed to install the gem

    thx
     
    John Miller, Mar 31, 2011
    #35
  16. Saeed Bhuta

    oleg.rikkers Guest

    env ARCHFLAGS="-arch x86_64" gem install pg
     
    oleg.rikkers, Sep 8, 2012
    #36
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.