Mac OS X and ruby-postgres again

Hello,

Yes I am new around here and to ruby in general. I have checked the
archive enough to know this question has come up before. I post it
again because I have tried all suggestions and have not come to a
satisfactory resolution.

I’m trying to build ruby-postgres extension under Mac OS X 10.2.6, ruby
1.6.7, PostgreSQL 7.3.3. Running extconf.rb returns the familiar error

checking for PQsetdbLogin() in -lpq… no
Could not find PostgreSQL libraries: Makefile not created

I have verified that the library file libpq.so and others mentioned in
the install note are present and with open perms. So this error message
that it cannot find the libraries it needs is confusing, to say the
least.

Any help very much appreciated.

I’m trying to build ruby-postgres extension under Mac OS X 10.2.6, ruby
1.6.7, PostgreSQL 7.3.3. Running extconf.rb returns the familiar error

checking for PQsetdbLogin() in -lpq… no
Could not find PostgreSQL libraries: Makefile not created

I have verified that the library file libpq.so and others mentioned in
the install note are present and with open perms. So this error
message
that it cannot find the libraries it needs is confusing, to say the
least.

“.so” is not an extension that one usually finds on Mac OS X. Most
often one would see “.a” or “.dylib”. Is libpq.so part of the Ruby
side of the equation, or part of the Postgre install?

I suspect that the extconf.rb file is trying to determine if the
routine it wants is in the file using a mechanism that is legitimate on
Linux, or other Unicies, but no valid on Mac OS X.

Can you find the relevant lines of extconf.rb that are generating the
error message?

Scott

How did you install postgresql? I had to specify the location of the
postgresql libraries when I installed ruby-postgres.

In my case I had installed postgresql via fink, so the postgres libs
were in /sw/lib/postgresql/ and the includes in /sw/include/postgresql/

I don’t remember (and don’t have sources for ruby-postgres on my system
at the moment) the exact argument so tp extconf.rb but the README or
INSTALL has the info you need to specify the library and include info.

let me know if this doesn’t work and I can figure it out again.

-Brian

···

On Wednesday, August 27, 2003, at 10:11 AM, Thomas Yager-Madden wrote:

Hello,

Yes I am new around here and to ruby in general. I have checked the
archive enough to know this question has come up before. I post it
again because I have tried all suggestions and have not come to a
satisfactory resolution.

I’m trying to build ruby-postgres extension under Mac OS X 10.2.6, ruby
1.6.7, PostgreSQL 7.3.3. Running extconf.rb returns the familiar error

checking for PQsetdbLogin() in -lpq… no
Could not find PostgreSQL libraries: Makefile not created

I have verified that the library file libpq.so and others mentioned in
the install note are present and with open perms. So this error
message
that it cannot find the libraries it needs is confusing, to say the
least.

Any help very much appreciated.

Earlier, I wrote:

I’m trying to build ruby-postgres extension under Mac OS X 10.2.6, ruby
1.6.7, PostgreSQL 7.3.3. Running extconf.rb returns the familiar error

checking for PQsetdbLogin() in -lpq… no
Could not find PostgreSQL libraries: Makefile not created

Now, thanks once again to everybody for the friendly, thoughtful and
helpful replies. I realize not everybody shares this problem, and much
appreciate the willingness to pitch in, especially given my newbishness.

I’m happy to report, mystery finally solved! :slight_smile: In desparation I
tried rebuilding both PostgreSQL and Ruby itself from latest sources,
only to have ruby-postgres extension fail again with the same error
noted above.

The answer turned out to be that I had to update the compiler link table
by running ranlib of libpq.a

sudo ranlib /usr/local/pgsql/lib/libpq.a

(This was suggested by a mailing list archive in which someone had run
into a similar problem trying to build the ‘psycopg’ python interface
for postgresql…
http://lists.initd.org/pipermail/psycopg/2002-September/001344.html)

I tried this, and it worked like a charm. OS X, PostgreSQL, and Ruby
now all get along great on my home box! I am very thrilled.

Although I found the solution elsewhere, I don’t think I would have kept
at it as long as I did, without the support from here, so thanks again.
Also, looking at the Google archive shows that this question has come up
in comp.lang.ruby at least twice before, and appears to have gone
unanswered. So, I’m not sure this comes up so often as to be
FAQ-worthy, but I bet it will come up again from somewhere, and ‘ranlib
libpq.a’ will be a useful bit of information to have tucked away
somewhere.

Cheers,
Thomas

Thanks for the reply

I did the postgresql install using well-known package from Marc Liyanage:

http://www.entropy.ch/software/macosx/

I have tried specifying library path when invoking extconf.rb, using
this syntax:

ruby extconf.rb --with-pgsql-include-dir=/usr/local/pgsql/include \
–with-pgsql-lib-dir=/usr/local/pgsql/lib

…but I still get the same error that it can’t find the postgres libs,
although I have verified that the libraries in question are present in
the specified location.

  • Thomas

In article E1F7CD79-D89B-11D7-A26A-000A95782782@forthillcompany.com,

···

Brian McCallister mccallister@forthillcompany.com wrote:

How did you install postgresql? I had to specify the location of the
postgresql libraries when I installed ruby-postgres.

In my case I had installed postgresql via fink, so the postgres libs
were in /sw/lib/postgresql/ and the includes in /sw/include/postgresql/

I don’t remember (and don’t have sources for ruby-postgres on my system
at the moment) the exact argument so tp extconf.rb but the README or
INSTALL has the info you need to specify the library and include info.

let me know if this doesn’t work and I can figure it out again.

-Brian

Thomas Yager-Madden wrote:

Thanks for the reply

I did the postgresql install using well-known package from Marc Liyanage:

http://www.entropy.ch/software/macosx/

I have tried specifying library path when invoking extconf.rb, using
this syntax:

ruby extconf.rb --with-pgsql-include-dir=/usr/local/pgsql/include \
–with-pgsql-lib-dir=/usr/local/pgsql/lib

…but I still get the same error that it can’t find the postgres libs,
although I have verified that the libraries in question are present in
the specified location

Are the postgres libs in the you library path (or whatever it’s called
in MacOS :slight_smile: )?

Michael

ruby extconf.rb --with-pgsql-include-dir=/usr/local/pgsql/include
–with-pgsql-lib-dir=/usr/local/pgsql/lib

…but I still get the same error that it can’t find the postgres libs,
although I have verified that the libraries in question are present in
the specified location.

Try adding
–with-ldflags=“-L /usr/local/pgsql/lib”

That will tell the linker to look in the sql folder for the libraries
as well.

Alternatively, you could symbolic link the libpq file into /usr/lib

Scott

I have tried specifying library path when invoking extconf.rb, using
this syntax:

ruby extconf.rb --with-pgsql-include-dir=/usr/local/pgsql/include
–with-pgsql-lib-dir=/usr/local/pgsql/lib

…but I still get the same error that it can’t find the postgres libs,
although I have verified that the libraries in question are present in
the specified location.

Another solution would be to edit the extconf.rb file, remove the
“have_func” calls that are preventing it from creating the make file,
create the makefile, and deal with linker errors that come up from the
make by editing the makefile.

Scott

I did the postgresql install using well-known package from Marc
Liyanage:

http://www.entropy.ch/software/macosx/

Cool, I never knew about that package :wink:

-Brian

mgarriss wrote:

Are the postgres libs in the you library path (or whatever it’s called
in MacOS :slight_smile: )?

Michael

Ugh. I mean:
Are the postgres libs in your library path (or whatever it’s called in
MacOS :slight_smile: )?

Michael

Are the postgres libs in the you library path (or whatever it’s called
in MacOS :slight_smile: )?

To answer the question “What is it called in Mac OS X”, repeat the
mantra “At it’s heart, Mac OS X is just Unix” to yourself over and over.

Scott

Thanks again to everyone for trying to help with this!

Of the various suggestions so far, this last has come closest to
working. Various suggestions (passing different parameter flags to the
extconf, changing env variables, symlinking the postgresql libs from
other paths) for getting extconf.rb to recognize my libpq and other
PostgreSQL library files all lead to the same result, that “have_func”
will not believe I have the libraries it wants, even though the
libraries in question appear, by any other lights, to be right there.

But if I stop it from checking for them (ie comment out all the
“if…have_func” lines, it will of course go ahead and create makefile.
At first, submitting this to ‘make’ errors out – which I would expect,
since the makefile isn’t really set up to link properly. But I have
managed to edit the makeflie, adding “-I/usr/local/pgsql/include” to the
CPPFLAGS line, and “-L/usr/local/pgsql/lib” to LIBPATH. At which point
it appears to allow me to ‘make’ and ‘make install’ without error.

However, any attempt to run actual ruby code using “require ‘postgres’”
(e.g. ‘test1.rb’ from the /samples that ship with the extension)
although it seems to load the module successfully (that is, I don’t get
a not found error for ‘postgres’ itself) then returns

dyld: ruby Undefined symbols:
_PQclear
_PQcmdStatus
_PQcmdTuples
_PQconsumeInput
_PQdb

(I’m guessing this list of undefined symbols, which is lengthy, is all
the methods in libpq.)

So, I feel like I’m getting closer, but still no cigar.

Any thoughts/suggestions? I’m at a loss. I’d really like to get this
working, though.

  • Thomas

In article F046CBC4-D8AB-11D7-B73A-000393803090@mac.com,

···

Scott Thompson easco@mac.com wrote:

I have tried specifying library path when invoking extconf.rb, using
this syntax:

ruby extconf.rb --with-pgsql-include-dir=/usr/local/pgsql/include
–with-pgsql-lib-dir=/usr/local/pgsql/lib

…but I still get the same error that it can’t find the postgres libs,
although I have verified that the libraries in question are present in
the specified location.

Another solution would be to edit the extconf.rb file, remove the
“have_func” calls that are preventing it from creating the make file,
create the makefile, and deal with linker errors that come up from the
make by editing the makefile.

Scott

(I'm guessing this list of undefined symbols, which is lengthy, is all
the methods in libpq.)

Well I don't know Mac OS X ("la chose") but on un*x this can be solved
by adding /usr/local/pgsql/lib in LD_LIBRARY_PATH. Probably there is
something similar with "la chose"

Guy Decoux

(I’m guessing this list of undefined symbols, which is lengthy, is
all
the methods in libpq.)

Well I don’t know Mac OS X (“la chose”) but on un*x this can be solved
by adding /usr/local/pgsql/lib in LD_LIBRARY_PATH. Probably there is
something similar with “la chose”

On Mac OS X, you probably want to add it to the “DYLD_LIBRARY_PATH”
environment variable. For (a lot) more info you can do “man dyld”

Scott