[fpc-pascal] Cannot load libpq.dylib on Mac OS X

Joao Morais jcmoraisjr at gmail.com
Sun Aug 4 02:07:54 CEST 2013


Hello FPC list

The following code raises the following exception on a Mac OS X Lion
with FPC 2.6.2:

========
$ cat pqconsole.lpr
program pqconsole;

{$mode objfpc}{$H+}

uses
  sqldb, pqconnection;

var
  vdb: TSQLQuery;
  vcon: TPQConnection;

begin
  vcon := TPQConnection.Create(nil);
  try
    vdb := TSQLQuery.Create(nil);
    try
      vcon.LoginPrompt := False;
      vcon.DatabaseName := 'bar';
      vcon.KeepConnection := True;
      vcon.Password := 'pwd';
      vcon.UserName := 'bar';
      vcon.HostName := 'localhost';
      vcon.Connected := True;
      vdb.DataBase := vcon;
    finally
      vdb.Free;
    end;
  finally
    vcon.Free;
  end;
end.
========

---------------
$ ./pqconsole
An unhandled exception occurred at $000CA921 :
EInOutError : Can not load PostgreSQL client library "libpq.dylib".
Check your installation.
---------------

What I have done so far:

1. export DYLD_LIBRARY_PATH=/Path/To/libpq.dylib/dir
(using Postgresql.app 9.2.4 from Heroku)

2. export DYLD_LIBRARY_PATH=.
and copying the libpq.dylib to the binary dir

3. Installed pg 9.2.4 from EnterpriseDB package

4. Restarted the SO =)

By the way, pgAdmin is installed and works flawlessly.

There are also some libpqs out there:

------------------
$ ll /usr/lib/libpq*
-rwxr-xr-x  1 root  wheel  163840  9 Abr 22:51 /usr/lib/libpq.5.4.dylib
lrwxr-xr-x  1 root  wheel      15 16 Nov  2012 /usr/lib/libpq.5.dylib
-> libpq.5.4.dylib
lrwxr-xr-x  1 root  wheel      15 16 Nov  2012 /usr/lib/libpq.dylib ->
libpq.5.4.dylib
------------------

Hints?

Joao Morais



More information about the fpc-pascal mailing list