Can't install PG gem

I'm running ruby 1.8.7 on rvm, and I'm trying to install the pg gem.
I've used macports to install postgresql 8.3. I'm running on a
dual-core mac. I try installing the pg gem with this command: (all
directories are not empty)

env ARCHFLAGS="-arch x86_64" gem install pg --
--with-pgsql-lib=/opt/local/lib/postgresql83
--with-pgsql-include=/opt/local/include/postgresql83/
(I've also tried w/the i386 flag)

Here's the response:

checking for pg_config... yes
MacOS X build: fixing architecture flags:
  using the value in ARCHFLAGS environment variable ("-arch x86_64").
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.

Any suggestions?

I really need help with this. Does anyone have any suggestions?

I’m running ruby 1.8.7 on rvm, and I’m trying to install the pg gem.

I’ve used macports to install postgresql 8.3. I’m running on a

dual-core mac. I try installing the pg gem with this command: (all

directories are not empty)

env ARCHFLAGS="-arch x86_64" gem install pg –

–with-pgsql-lib=/opt/local/lib/postgresql83

–with-pgsql-include=/opt/local/include/postgresql83/

(I’ve also tried w/the i386 flag)

Here’s the response:

checking for pg_config… yes

MacOS X build: fixing architecture flags:

using the value in ARCHFLAGS environment variable ("-arch x86_64").

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.

These are my notes on getting pg to install on rvm – I think the big deal was to make sure you are pointing to the actual bin directory of postgres, wherever it happens to be installed, so you might need to change the directory:

PATH=/library/postgresql/8.4/bin:$PATH gem install pg --no-rdoc --no-ri
(note - the path is to the postgres server bin)

For all of you guys who like to work with finance applications:

I have added a release 1.00.01 of the library long-decimal to
rubyforge.org and rubygems.org,
which has been tested for JRuby, Ruby 1.8, Ruby 1.9 and Rubinius.

This adds a type for doing calculations with fixed point numbers:

+, -, *, /
sqrt, cbrt
** (power)
log, exp (also for base 2 and 10)
pi

and quite a few rounding rules, including what is needed for currencies
which do have something
like cent (0.01), but the smallest unit actually occuring is 0.05 or
0.02. This can be supported by
calling

x.round_to_allowed_remainders(2, [0, 5], 10, LongDecimal::ROUND_HALF_UP)

(we want 2 digits after the decimal point and the last digit should be 5
or 10 and we
round to the nearest allowed value, (preferring rounding up if ambiguous).

Installation is done by

gem install long-decimal

Usage:

require "rubygems"
require "long-decimal"

x = LongDecimal("0.080")
y = LongDecimal("37.938")
puts (x+y).to_s
=> "38.018"
put (x-y).to_s
=> "-37.858"
puts (x*y).to_s
=> "3.035040"

Potential future developments:
* adding support for active record to have a better representation of
DECIMAL() from databases.
* adding more functions (sin, cos, tan, cot, sec, csc, asin, acos,...,
sinh, cosh,... asinh, acosh,...)

Any comments are welcome!!

Best regards

Karl