Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Installing Pg gem for PostGreSQL 8.4

450 views
Skip to first unread message

Saeed Bhuta

unread,
Feb 26, 2010, 9:16:36 AM2/26/10
to
Hi All,

I want to save data from a ruby script into a table in a PostGreSQL 8.4
database.

After looking into PostGreSQL connectivity in Ruby, I have come accross
the 'pg' gem.

I attempted to install the gem with the command: 'sudo gem install pg'
but got the following error:
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 main() in -lpq... no
checking for main() in -llibpq... no
checking for main() in -lms/libpq... no
*** 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-dir
--without-pg-dir
--with-pg-include
--without-pg-include=${pg-dir}/include
--with-pg-lib
--without-pg-lib=${pg-dir}/lib
--with-pqlib
--without-pqlib
--with-libpqlib
--without-libpqlib
--with-ms/libpqlib
--without-ms/libpqlib
Could not find PostgreSQL build environment (libraries & headers):
Makefile not created


Gem files will remain installed in /var/lib/gems/1.8/gems/pg-0.8.0 for
inspection.
Results logged to /var/lib/gems/1.8/gems/pg-0.8.0/ext/gem_make.out

Would appreciate it if someone could point me in the right direction.

Saeed.
--
Posted via http://www.ruby-forum.com/.

Shashank Tiwari

unread,
Feb 26, 2010, 11:33:00 AM2/26/10
to
[Note: parts of this message were removed to make it a legal post.]

Are you installing this on a mac, windows or a linux environment? You may
need to make sure your C/C++ compiler is configured on the platform for the
native extensions to compile and install.

Thanks, Shashank

Saeed Bhuta

unread,
Feb 26, 2010, 11:37:24 AM2/26/10
to
Shashank Tiwari wrote:
> Are you installing this on a mac, windows or a linux environment? You
> may
> need to make sure your C/C++ compiler is configured on the platform for
> the
> native extensions to compile and install.
>
> Thanks, Shashank

Hi Shashank,

Thanks for replying. I'm using Linux Ubuntu Karmic Koala.

Reid Thompson

unread,
Feb 26, 2010, 12:54:46 PM2/26/10
to
On Fri, 2010-02-26 at 23:16 +0900, Saeed Bhuta wrote:

> Could not find PostgreSQL build environment (libraries & headers):

you need to install the postgresql development packages


Saeed Bhuta

unread,
Mar 1, 2010, 3:44:43 AM3/1/10
to
> you need to install the postgresql development packages

I think I've done this already. Nonetheless, I'm going to try and
install it again. Do you know the name of the development packages?

Thanks,

Saeed Bhuta

unread,
Mar 1, 2010, 3:56:05 AM3/1/10
to
Saeed Bhuta wrote:
> Shashank Tiwari wrote:
>> Are you installing this on a mac, windows or a linux environment? You
>> may
>> need to make sure your C/C++ compiler is configured on the platform for
>> the
>> native extensions to compile and install.
>>
>> Thanks, Shashank

I just installed the 'libecpg-dev' package and am now getting the
following error when trying to install the pg gem:

"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"

Reid Thompson

unread,
Mar 1, 2010, 8:45:40 AM3/1/10
to
Run this...
$ dpkg --get-selections
and paste the results in a pastebin.

At this point, the gems is stating that it cannot find libpq ( the
postgresql C client library ). Do you have the postgresql client
packages installed?

reid

Reid Thompson

unread,
Mar 1, 2010, 8:48:27 AM3/1/10
to
On Mon, 2010-03-01 at 17:56 +0900, Saeed Bhuta wrote:
> Saeed Bhuta wrote:
> > Shashank Tiwari wrote:
> >> Are you installing this on a mac, windows or a linux environment? You
> >> may
> >> need to make sure your C/C++ compiler is configured on the platform for
> >> the
> >> native extensions to compile and install.
> >>
> >> Thanks, Shashank
>
> I just installed the 'libecpg-dev' package and am now getting the
> following error when trying to install the pg gem:

I believe the libecpg-dev package would only provide the required
packages for developing embedded sql programs.

Open synaptic, scroll down to the postgresql section, and look at the
available packages. Make sure you have appropriate server and client
packages installed as well as their associated dev packages.

Saeed Bhuta

unread,
Mar 1, 2010, 9:19:24 AM3/1/10
to
Here is the result of the '$ dpkg --get-selections' command;
http://pastebin.com/6SRaW4KL

Looked in Synaptic, seemed like all the right server and client packages
were installed.

Lars Haugseth

unread,
Mar 1, 2010, 10:33:39 AM3/1/10
to
* Saeed Bhuta <saeed...@placr.co.uk> wrote:
>
> Here is the result of the '$ dpkg --get-selections' command;
> http://pastebin.com/6SRaW4KL
>
> Looked in Synaptic, seemed like all the right server and client packages
> were installed.

Looks like you're missing the libpq5 and libpq-dev packages.

--
Lars Haugseth

Saeed Bhuta

unread,
Mar 1, 2010, 10:39:40 AM3/1/10
to

When I try to install them using the command:

sudo apt-get libpq5 libpq-dev

I get the message;

Reading package lists... Done
Building dependency tree
Reading state information... Done
libpq5 is already the newest version.
libpq-dev is already the newest version.
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.

:S

Reid Thompson

unread,
Mar 1, 2010, 10:50:39 AM3/1/10
to
On Mon, 2010-03-01 at 23:19 +0900, Saeed Bhuta wrote:
> Here is the result of the '$ dpkg --get-selections' command;
> http://pastebin.com/6SRaW4KL
>
> Looked in Synaptic, seemed like all the right server and client packages
> were installed.

pastebin the output of

$ apt-cache search postgresql

Saeed Bhuta

unread,
Mar 1, 2010, 10:58:28 AM3/1/10
to

http://pastebin.com/7qCufpx1

I don't think that is all of the output, I copied what was displayed on
the terminal.

Many Thanks,

Saeed

Reid Thompson

unread,
Mar 1, 2010, 4:41:19 PM3/1/10
to

what do the following commands return

$pg_config --libdir


$pg_config --bindir

Saeed Bhuta

unread,
Mar 2, 2010, 3:24:04 AM3/2/10
to

pg_config --libdir
/usr/lib

pg_config --bindir
/usr/lib/postgresql/8.4/bin

Reid Thompson

unread,
Mar 2, 2010, 9:01:58 AM3/2/10
to

what does
$ ls -lrt /usr/lib/*libpq*

return

Saeed Bhuta

unread,
Mar 2, 2010, 9:09:08 AM3/2/10
to


ls -lrt /usr/lib/*libpq*
-rw-r--r-- 1 root root 217474 2009-09-09 17:51 /usr/lib/libpq.a
-rw-r--r-- 1 root root 151036 2009-09-09 17:51 /usr/lib/libpq.so.5.2
lrwxrwxrwx 1 root root 12 2009-11-30 12:12 /usr/lib/libpq.so.5 ->
libpq.so.5.2
lrwxrwxrwx 1 root root 12 2010-03-02 10:12 /usr/lib/libpq.so ->
libpq.so.5.2

Reid Thompson

unread,
Mar 2, 2010, 11:24:00 AM3/2/10
to

ok - that all looks right so far.
per your original email

> Check the mkmf.log file for more
> details.

what does mkmf.log contain?

on my box this file is located at

/usr/lib/ruby/gems/1.8/gems/pg-0.8.0/ext/mkmf.log

That may or may not be where your's is located.

Reid Thompson

unread,
Mar 2, 2010, 11:28:27 AM3/2/10
to

doh -- your's is likely here

Saeed Bhuta

unread,
Mar 2, 2010, 11:49:28 AM3/2/10
to
Reid Thompson wrote:
> On Tue, 2010-03-02 at 11:23 -0500, Reid Thompson wrote:
>> > > $ ls -lrt /usr/lib/*libpq*
>> > libpq.so.5.2

>>
>> That may or may not be where your's is located.
>
> doh -- your's is likely here
>
>> Gem files will remain installed in /var/lib/gems/1.8/gems/pg-0.9.0
> for

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

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

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

"gcc -E -I. -I/usr/lib/ruby/1.8/i486-linux -I.
-I/usr/include/postgresql/include -D_FILE_OFFSET_BITS=64
-I/usr/include/postgresql -fno-strict-aliasing -g -g -O2 -fPIC
conftest.c -o conftest.i"
checked program was:
/* begin */
1: #include <libpq-fe.h>
/* end */

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

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

"gcc -E -I. -I/usr/lib/ruby/1.8/i486-linux -I.
-I/usr/include/postgresql/include -D_FILE_OFFSET_BITS=64
-I/usr/include/postgresql -fno-strict-aliasing -g -g -O2 -fPIC
conftest.c -o conftest.i"
checked program was:
/* begin */
1: #include <libpq/libpq-fs.h>
/* end */

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

have_library: checking for PQconnectdb() in
-l/usr/include/postgresql/... -------------------- no

"gcc -o conftest -I. -I/usr/lib/ruby/1.8/i486-linux -I.
-I/usr/include/postgresql/include -D_FILE_OFFSET_BITS=64
-I/usr/include/postgresql -fno-strict-aliasing -g -g -O2 -fPIC
conftest.c -L. -L/usr/lib -L/usr/include/postgresql/lib -L.
-Wl,-Bsymbolic-functions -rdynamic -Wl,-export-dynamic -L/usr/lib
-lruby1.8-static -l/usr/include/postgresql/ -lpthread -lrt -ldl -lcrypt
-lm -lc"
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 */

"gcc -o conftest -I. -I/usr/lib/ruby/1.8/i486-linux -I.
-I/usr/include/postgresql/include -D_FILE_OFFSET_BITS=64
-I/usr/include/postgresql -fno-strict-aliasing -g -g -O2 -fPIC
conftest.c -L. -L/usr/lib -L/usr/include/postgresql/lib -L.
-Wl,-Bsymbolic-functions -rdynamic -Wl,-export-dynamic -L/usr/lib
-lruby1.8-static -l/usr/include/postgresql/ -lpthread -lrt -ldl -lcrypt
-lm -lc"
/usr/bin/ld: cannot find -l/usr/include/postgresql/
collect2: ld returned 1 exit status
checked program was:
/* begin */
1: /*top*/
2: int main() { return 0; }
3: int t() { PQconnectdb(); return 0; }
/* end */

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

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

"gcc -o conftest -I. -I/usr/lib/ruby/1.8/i486-linux -I.
-I/usr/include/postgresql/include -D_FILE_OFFSET_BITS=64
-I/usr/include/postgresql -fno-strict-aliasing -g -g -O2 -fPIC
conftest.c -L. -L/usr/lib -L/usr/include/postgresql/lib -L.
-Wl,-Bsymbolic-functions -rdynamic -Wl,-export-dynamic -L/usr/lib
-lruby1.8-static -llibpq -lpthread -lrt -ldl -lcrypt -lm -lc"
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; }

Reid Thompson

unread,
Mar 2, 2010, 1:40:09 PM3/2/10
to
what does this return
$ pg_config --includedir

Saeed Bhuta

unread,
Mar 3, 2010, 3:11:29 AM3/3/10
to
Reid Thompson wrote:
> what does this return
> $ pg_config --includedir

pg_config --includedir
/usr/include/postgresql

Reid Thompson

unread,
Mar 3, 2010, 8:53:39 AM3/3/10
to
On 3/3/2010 3:11 AM, Saeed Bhuta wrote:
> Reid Thompson wrote:
>> what does this return
>> $ pg_config --includedir
>
> pg_config --includedir
> /usr/include/postgresql

and
$ ls /usr/include/postgresql

Reid Thompson

unread,
Mar 3, 2010, 8:54:20 AM3/3/10
to
On 3/3/2010 3:11 AM, Saeed Bhuta wrote:
> Reid Thompson wrote:
>> what does this return
>> $ pg_config --includedir
>
> pg_config --includedir
> /usr/include/postgresql

actually, make that

$ ls -lrt /usr/include/postgresql

Saeed Bhuta

unread,
Mar 3, 2010, 9:59:16 AM3/3/10
to

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

Reid Thompson

unread,
Mar 3, 2010, 11:01:53 AM3/3/10
to


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

Saeed Bhuta

unread,
Mar 3, 2010, 11:18:15 AM3/3/10
to
Reid Thompson wrote:
> On Wed, 2010-03-03 at 23:59 +0900, Saeed Bhuta wrote:
>> >
>> -rw-r--r-- 1 root root 7583 2009-09-09 17:49 pg_config_manual.h
>> drwxr-xr-x 3 root root 4096 2010-03-02 10:13 8.4
> 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

Deleted the directory and tried the install again but no luck;

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

Tor Erik Linnerud

unread,
Mar 4, 2010, 9:35:42 AM3/4/10
to
> 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)

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

Luis Lavena

unread,
Mar 4, 2010, 11:23:56 AM3/4/10
to

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

Tor Erik Linnerud

unread,
Mar 4, 2010, 1:26:38 PM3/4/10
to
Luis Lavena wrote:

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

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

Reid Thompson

unread,
Mar 4, 2010, 2:41:49 PM3/4/10
to
On Fri, 2010-03-05 at 03:26 +0900, Tor Erik Linnerud wrote:
> -lms/libpq
what is this supposed to be?

Luis Lavena

unread,
Mar 4, 2010, 3:46:46 PM3/4/10
to

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

Michael Granger

unread,
Mar 4, 2010, 6:07:01 PM3/4/10
to
On 03/04/2010 06:35 AM, Tor Erik Linnerud wrote:
>> 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)
>
> 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

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 <g...@FaerieMUD.org>
Rubymage, Architect, Believer
http://FaerieMUD.org/

Tor Erik Linnerud

unread,
Mar 5, 2010, 4:22:50 AM3/5/10
to
> I assume you're the anonymous creator of this ticket:
> http://bitbucket.org/ged/ruby-pg/issue/24/090-gem-fails-to-build
>

That is correct :)

> 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".

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.

John Miller

unread,
Mar 31, 2011, 10:48:05 AM3/31/11
to
This post was helpful because it helped me to realize that I needed gcc
installed to install the gem

thx

oleg.r...@gmail.com

unread,
Sep 8, 2012, 3:21:50 PM9/8/12
to
env ARCHFLAGS="-arch x86_64" gem install pg
0 new messages