Trying to install pg on 32bit Snow Leopard 10.6


T

theLemcke

I'm trying to install the "pg" gem on 32-bit snow leopard and I'm
encountering the following error:

$ sudo env ARCHFLAGS="-arch i386" gem install pg -v=0.9.0
Building native extensions. This could take a while...
ERROR: Error installing pg:
ERROR: Failed to build gem native extension.

/opt/local/bin/ruby extconf.rb
checking for pg_config... yes
MacOS X build: fixing architecture flags:
using the value in ARCHFLAGS environment variable ("-arch i386").
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
--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=/opt/local/bin/ruby
--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

Any suggestions or help?
 
Ad

Advertisements

T

theLemcke

I'm trying to install the "pg" gem on 32-bit snow leopard and I'm
encountering the following error:

$ sudo env ARCHFLAGS="-arch i386" gem install pg -v=0.9.0
Building native extensions.  This could take a while...
ERROR:  Error installing pg:
        ERROR: Failed to build gem native extension.

/opt/local/bin/ruby extconf.rb
checking for pg_config... yes
MacOS X build: fixing architecture flags:
  using the value in ARCHFLAGS environment variable ("-arch i386").
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
        --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=/opt/local/bin/ruby
        --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

Any suggestions or help?

Mkmf.log file for reference:


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

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

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

"/usr/bin/gcc-4.2 -E -I. -I/opt/local/lib/ruby/1.8/i686-darwin10 -I. -
I/opt/local/include -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -I/opt/local/
include -I/opt/local/include/postgresql84 -pipe -O2 -fno-common -pipe
-fno-common -arch i386 conftest.c -o conftest.i"
checked program was:
/* begin */
1: #include <libpq-fe.h>
/* end */

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

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

"/usr/bin/gcc-4.2 -E -I. -I/opt/local/lib/ruby/1.8/i686-darwin10 -I. -
I/opt/local/include -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -I/opt/local/
include -I/opt/local/include/postgresql84 -pipe -O2 -fno-common -pipe
-fno-common -arch i386 conftest.c -o conftest.i"
checked program was:
/* begin */
1: #include <libpq/libpq-fs.h>
/* end */

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

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

"/usr/bin/gcc-4.2 -o conftest -I. -I/opt/local/lib/ruby/1.8/i686-
darwin10 -I. -I/opt/local/include -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -
I/opt/local/include -I/opt/local/include/postgresql84 -pipe -O2 -fno-
common -pipe -fno-common -arch i386 conftest.c -L. -L/opt/local/lib
-L/opt/local/lib -L. -L/opt/local/lib -L/opt/local/lib/postgresql84 -
arch i386 -arch i386 -lruby-static -lpq -lpthread -ldl -lobjc "
conftest.c: In function ‘t’:
conftest.c:3: error: ‘PQconnectdb’ undeclared (first use in this
function)
conftest.c:3: error: (Each undeclared identifier is reported only once
conftest.c:3: error: for each function it appears in.)
checked program was:
/* begin */
1: /*top*/
2: int main() { return 0; }
3: int t() { void ((*volatile p)()); p = (void ((*)()))PQconnectdb;
return 0; }
/* end */

"/usr/bin/gcc-4.2 -o conftest -I. -I/opt/local/lib/ruby/1.8/i686-
darwin10 -I. -I/opt/local/include -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -
I/opt/local/include -I/opt/local/include/postgresql84 -pipe -O2 -fno-
common -pipe -fno-common -arch i386 conftest.c -L. -L/opt/local/lib
-L/opt/local/lib -L. -L/opt/local/lib -L/opt/local/lib/postgresql84 -
arch i386 -arch i386 -lruby-static -lpq -lpthread -ldl -lobjc "
ld: warning: in /opt/local/lib/postgresql84/libpq.dylib, file was
built for unsupported file format which is not the architecture being
linked (i386)
Undefined symbols:
"_PQconnectdb", referenced from:
_t in ccNZOcje.o
ld: symbol(s) not found
collect2: ld returned 1 exit status
checked program was:
/* begin */
1: /*top*/
2: int main() { return 0; }
3: int t() { PQconnectdb(); return 0; }
/* end */

"/usr/bin/gcc-4.2 -o conftest -I. -I/opt/local/lib/ruby/1.8/i686-
darwin10 -I. -I/opt/local/include -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -
I/opt/local/include -I/opt/local/include/postgresql84 -pipe -O2 -fno-
common -pipe -fno-common -arch i386 conftest.c -L. -L/opt/local/lib
-L/opt/local/lib -L. -L/opt/local/lib -L/opt/local/lib/postgresql84 -
arch i386 -arch i386 -lruby-static -lpq -lpthread -ldl -lobjc "
ld: warning: in /opt/local/lib/postgresql84/libpq.dylib, file was
built for unsupported file format which is not the architecture being
linked (i386)
Undefined symbols:
"_PQconnectdb", referenced from:
_t in ccJOW4Il.o
ld: symbol(s) not found
collect2: ld returned 1 exit status
checked program was:
/* begin */
1: int PQconnectdb();
2: /*top*/
3: /*
4: * http://trac.macports.org/ticket/3604
5: * gcc 4.0 on 10.4 has a problem
6: */
7: int main() { return 0; }
8: int t() { PQconnectdb(); return 0; }
/* end */

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

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

"/usr/bin/gcc-4.2 -o conftest -I. -I/opt/local/lib/ruby/1.8/i686-
darwin10 -I. -I/opt/local/include -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -
I/opt/local/include -I/opt/local/include/postgresql84 -pipe -O2 -fno-
common -pipe -fno-common -arch i386 conftest.c -L. -L/opt/local/lib
-L/opt/local/lib -L. -L/opt/local/lib -L/opt/local/lib/postgresql84 -
arch i386 -arch i386 -lruby-static -llibpq -lpthread -ldl -lobjc
"
conftest.c: In function ‘t’:
conftest.c:3: error: ‘PQconnectdb’ undeclared (first use in this
function)
conftest.c:3: error: (Each undeclared identifier is reported only once
conftest.c:3: error: for each function it appears in.)
checked program was:
/* begin */
1: /*top*/
2: int main() { return 0; }
3: int t() { void ((*volatile p)()); p = (void ((*)()))PQconnectdb;
return 0; }
/* end */

"/usr/bin/gcc-4.2 -o conftest -I. -I/opt/local/lib/ruby/1.8/i686-
darwin10 -I. -I/opt/local/include -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -
I/opt/local/include -I/opt/local/include/postgresql84 -pipe -O2 -fno-
common -pipe -fno-common -arch i386 conftest.c -L. -L/opt/local/lib
-L/opt/local/lib -L. -L/opt/local/lib -L/opt/local/lib/postgresql84 -
arch i386 -arch i386 -lruby-static -llibpq -lpthread -ldl -lobjc
"
ld: library not found for -llibpq
collect2: ld returned 1 exit status
checked program was:
/* begin */
1: /*top*/
2: int main() { return 0; }
3: int t() { PQconnectdb(); return 0; }
/* end */

"/usr/bin/gcc-4.2 -o conftest -I. -I/opt/local/lib/ruby/1.8/i686-
darwin10 -I. -I/opt/local/include -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -
I/opt/local/include -I/opt/local/include/postgresql84 -pipe -O2 -fno-
common -pipe -fno-common -arch i386 conftest.c -L. -L/opt/local/lib
-L/opt/local/lib -L. -L/opt/local/lib -L/opt/local/lib/postgresql84 -
arch i386 -arch i386 -lruby-static -llibpq -lpthread -ldl -lobjc
"
ld: library not found for -llibpq
collect2: ld returned 1 exit status
checked program was:
/* begin */
1: int PQconnectdb();
2: /*top*/
3: /*
4: * http://trac.macports.org/ticket/3604
5: * gcc 4.0 on 10.4 has a problem
6: */
7: int main() { return 0; }
8: int t() { PQconnectdb(); return 0; }
/* end */

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

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

"/usr/bin/gcc-4.2 -o conftest -I. -I/opt/local/lib/ruby/1.8/i686-
darwin10 -I. -I/opt/local/include -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -
I/opt/local/include -I/opt/local/include/postgresql84 -pipe -O2 -fno-
common -pipe -fno-common -arch i386 conftest.c -L. -L/opt/local/lib
-L/opt/local/lib -L. -L/opt/local/lib -L/opt/local/lib/postgresql84 -
arch i386 -arch i386 -lruby-static -lms/libpq -lpthread -ldl -
lobjc "
conftest.c: In function ‘t’:
conftest.c:3: error: ‘PQconnectdb’ undeclared (first use in this
function)
conftest.c:3: error: (Each undeclared identifier is reported only once
conftest.c:3: error: for each function it appears in.)
checked program was:
/* begin */
1: /*top*/
2: int main() { return 0; }
3: int t() { void ((*volatile p)()); p = (void ((*)()))PQconnectdb;
return 0; }
/* end */

"/usr/bin/gcc-4.2 -o conftest -I. -I/opt/local/lib/ruby/1.8/i686-
darwin10 -I. -I/opt/local/include -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -
I/opt/local/include -I/opt/local/include/postgresql84 -pipe -O2 -fno-
common -pipe -fno-common -arch i386 conftest.c -L. -L/opt/local/lib
-L/opt/local/lib -L. -L/opt/local/lib -L/opt/local/lib/postgresql84 -
arch i386 -arch i386 -lruby-static -lms/libpq -lpthread -ldl -
lobjc "
ld: library not found for -lms/libpq
collect2: ld returned 1 exit status
checked program was:
/* begin */
1: /*top*/
2: int main() { return 0; }
3: int t() { PQconnectdb(); return 0; }
/* end */

"/usr/bin/gcc-4.2 -o conftest -I. -I/opt/local/lib/ruby/1.8/i686-
darwin10 -I. -I/opt/local/include -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -
I/opt/local/include -I/opt/local/include/postgresql84 -pipe -O2 -fno-
common -pipe -fno-common -arch i386 conftest.c -L. -L/opt/local/lib
-L/opt/local/lib -L. -L/opt/local/lib -L/opt/local/lib/postgresql84 -
arch i386 -arch i386 -lruby-static -lms/libpq -lpthread -ldl -
lobjc "
ld: library not found for -lms/libpq
collect2: ld returned 1 exit status
checked program was:
/* begin */
1: int PQconnectdb();
2: /*top*/
3: /*
4: * http://trac.macports.org/ticket/3604
5: * gcc 4.0 on 10.4 has a problem
6: */
7: int main() { return 0; }
8: int t() { PQconnectdb(); return 0; }
/* end */

--------------------
 
T

theLemcke

[Note:  parts of this message were removed to make it a legal post.]

Try to use Homebrew:

http://mxcl.github.com/homebrew/htt...010/04/29/postgresql_on_snow_leopard_with_rai...

Enjoy!

Daniel G.

2011/2/28 theLemcke <[email protected]>






I'm trying to install the "pg" gem on 32-bit snow leopard and I'm
encountering the following error:
$ sudo env ARCHFLAGS="-arch i386" gem install pg -v=0.9.0
Building native extensions.  This could take a while...
ERROR:  Error installing pg:
       ERROR: Failed to build gem native extension.
/opt/local/bin/ruby extconf.rb
checking for pg_config... yes
MacOS X build: fixing architecture flags:
 using the value in ARCHFLAGS environment variable ("-arch i386").
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
       --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=/opt/local/bin/ruby
       --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
Any suggestions or help?

Any other suggestions? I already have port installed and it's
difficult to manage both at the same time.
 
B

Brian Ledsworth

I'm assuming you downloaded and and installed the PostgreSQL client?

I just installed the Gem a few weeks ago and had to add the bin dir to
my path (e.g. /Library/PostgreSQL/9.0/bin) right after I installed the
client. Try that if you haven't.

I hope this helps!

Brian
 
B

Brian Candler

Chris Lemcke wrote in post #984496:
have_library: checking for PQconnectdb() in -lpq...
-------------------- no

"/usr/bin/gcc-4.2 -o conftest -I. -I/opt/local/lib/ruby/1.8/i686-
darwin10 -I. -I/opt/local/include -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -
I/opt/local/include -I/opt/local/include/postgresql84 -pipe -O2 -fno-
common -pipe -fno-common -arch i386 conftest.c -L. -L/opt/local/lib
-L/opt/local/lib -L. -L/opt/local/lib -L/opt/local/lib/postgresql84 -
arch i386 -arch i386 -lruby-static -lpq -lpthread -ldl -lobjc "
conftest.c: In function t:
conftest.c:3: error: PQconnectdb undeclared (first use in this
function)
conftest.c:3: error: (Each undeclared identifier is reported only once
conftest.c:3: error: for each function it appears in.)
checked program was:
/* begin */
1: /*top*/
2: int main() { return 0; }
3: int t() { void ((*volatile p)()); p = (void ((*)()))PQconnectdb;
return 0; }
/* end */

Strange, looks like this conftest forgot to #include the header or
declare PQconnectdb.

The later tests declare
int PQconnectdb();
but they are looking for different libraries, so fail later in the
linking stage.

Raise a ticket on macports?
 
F

Fernando Perez

Chris Lemcke wrote in post #984495:
I'm trying to install the "pg" gem on 32-bit snow leopard and I'm
encountering the following error:

The solution is to simply export the correct $PATH.

How did you install PostgreSQL?

Using Macports, when I perform a locate of "pg_config" it returns:
/opt/local/lib/postgresql90/bin/pg_config

therefore I have to:

export PATH=/opt/local/lib/postgresql90/bin:$PATH

then run the command "gem install pg" and it works


Your mileage may vary.
 
Ad

Advertisements

M

Michael Granger

=20
I'm trying to install the "pg" gem on 32-bit snow leopard and I'm
encountering the following error:
=20
$ sudo env ARCHFLAGS=3D"-arch i386" gem install pg -v=3D0.9.0
Building native extensions. This could take a while...
ERROR: Error installing pg:
ERROR: Failed to build gem native extension.
=20
[...]
Mkmf.log file for reference:
=20
[...]
have_library: checking for PQconnectdb() in -lpq...
-------------------- no
=20
"/usr/bin/gcc-4.2 -o conftest -I. -I/opt/local/lib/ruby/1.8/i686-
darwin10 -I. -I/opt/local/include -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE = -
I/opt/local/include -I/opt/local/include/postgresql84 -pipe -O2 -fno-
common -pipe -fno-common -arch i386 conftest.c -L. -L/opt/local/lib
-L/opt/local/lib -L. -L/opt/local/lib -L/opt/local/lib/postgresql84 -
arch i386 -arch i386 -lruby-static -lpq -lpthread -ldl -lobjc "
conftest.c: In function =91t=92:
conftest.c:3: error: =91PQconnectdb=92 undeclared (first use in this
function)
conftest.c:3: error: (Each undeclared identifier is reported only once
conftest.c:3: error: for each function it appears in.)
checked program was:
/* begin */
1: /*top*/
2: int main() { return 0; }
3: int t() { void ((*volatile p)()); p =3D (void ((*)()))PQconnectdb;
return 0; }
/* end */
=20
"/usr/bin/gcc-4.2 -o conftest -I. -I/opt/local/lib/ruby/1.8/i686-
darwin10 -I. -I/opt/local/include -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE = -
I/opt/local/include -I/opt/local/include/postgresql84 -pipe -O2 -fno-
common -pipe -fno-common -arch i386 conftest.c -L. -L/opt/local/lib
-L/opt/local/lib -L. -L/opt/local/lib -L/opt/local/lib/postgresql84 -
arch i386 -arch i386 -lruby-static -lpq -lpthread -ldl -lobjc "
ld: warning: in /opt/local/lib/postgresql84/libpq.dylib, file was
built for unsupported file format which is not the architecture being
linked (i386)
Undefined symbols:
"_PQconnectdb", referenced from:
_t in ccNZOcje.o
ld: symbol(s) not found

Your PostgreSQL client library is x86_64, not i386. The "file was built =
for unsupported file format which is not the architecture being linked =
(i386)" pretty much says it all.

I'd make sure pg_config is in your path, then try running it without the =
ARCHFLAGS override.
 

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. After that, you can post your question and our members will help you out.

Ask a Question

Top