Posts mit dem Label OSX werden angezeigt. Alle Posts anzeigen
Posts mit dem Label OSX werden angezeigt. Alle Posts anzeigen

Freitag, 21. Januar 2011

PostgreSQL vs. libreadline on OSX

Today Thom Brown posted a bug report to pgsql-bugs, where he asked for a potential issue with the interactive terminal psql. As the following reply from Tom Lane explained, this is a long standing issue with the libedit package Apple ships with OSX. Yes, libedit, since libreadline under OSX is just a symlink to libedit:


% ls -la /usr/lib/libreadline.dylib
lrwxr-xr-x 1 root wheel 15 15 Sep 2009 /usr/lib/libreadline.dylib@ -> libedit.2.dylib


If you just configure your PostgreSQL build without any special options, the PostgreSQL binaries will be linked against libedit.
There were several discussions about this in the past and this was even reported to Apple. However, since now (i'm on OSX 10.6.6 for example), nothing happened and the shipped libedit is still unusable with psql.

If you really need to build your own PostgreSQL binaries on OSX (for example you want do a review for a patch in the current CommitFest ;)), i always recommend to use MacPorts and their packaging. I use it for nearly two years and it works quite well (well, at least all libraries required by my installation are working). There's a fairly good instruction on how to setup MacPorts on your MacBook. If you have done your package installation, simply point the configure script to the correct location of the libraries and header files:


./configure --with-libraries=/opt/local/lib --with-includes=/opt/local/include ...


/opt/local is the default location for libraries installed from MacPorts. You also might want to specify additional options. At least, --with-includes and --with-libraries are necessary to point your PostgreSQL builds to the correct libraries.

Freitag, 5. November 2010

Building Slony-I on OSX

Just stumpled across this today while trying to build a fresh git clone of Slony-I on my MacBook; To build Slony-I on a OSX box (in my case 10.6.4), you might do the following on your box:


% ./configure --prefix=$PGSQL_HOME --with-pgconfigdir=$PGSQL_HOME/bin
...
configure: error: Headers for libpqserver are not found in the includeserverdir.
This is the path to postgres.h. Please specify the includeserverdir with
--with-pgincludeserverdir=<dir>


Now, of course you are following this gentle hint and try again with a proper include path:


% ./configure --prefix=$PGSQL_HOME --with-pgconfigdir=$PGSQL_HOME/bin --with-pgincludeserverdir=$PGSQL_HOME/include/server
...
configure: error: Headers for libpqserver are not found in the includeserverdir.
This is the path to postgres.h. Please specify the includeserverdir with
--with-pgincludeserverdir=<dir>


Uhm, doesn't work either. A good way to find out what's really going on now is to have a look into the config.log (located in the Slony-I source directory) and check what exactly is causing this error. Open the file and simply search for postgres.h. You'll find the following line there (ignore my path names here, they surely differ from yours):


In file included from /Users/bernd/pgsql-dev/install/REL9_0_STABLE/include/server/postgres.h:47,
from conftest.c:80:
/Users/bernd/pgsql-dev/install/REL9_0_STABLE/include/server/c.h:99:21: error: libintl.h: No such file or directory


Ah okay, it is indeed failing compiling the conftest.c file while including the PostgreSQL headers. Now that i saw this i remembered that i had my local development PostgreSQL-builds configured with --enable-nls, which need to include gettext/libintl. Since OSX doesn't ship with the latter, they were installed from MacPorts, which is located in /opt/local/include. So the solution is to just include those header path as well. PostgreSQL has an extra configure switch --with-includes, unfortunately the configure script in Slony-I is missing this, so i decided to go with this:


% CFLAGS='-I /opt/local/include' ./configure --prefix=$PGSQL_HOME --with-pgconfigdir=$PGSQL_HOME/bin


That worked and i was finally able to sucessfully build Slony-I on my MacBook. Hope this helps anybody facing the same issue.