Monday, 29 October 2007

[update] PostgreSQL Problems in Leopard When Using MacPorts

(update): scroll to the bottom of this posts for an update.

It is not possible to compile the current PostgreSQL package in Macports using Leopard. The following error occurs:


gcc -no-cpp-precomp -O2 -Wall -Wmissing-prototypes -Wpointer-arith -Winline -Wdeclaration-after-statement -Wendif-labels -fno-strict-aliasing -L../../src/port -L/opt/local/lib  -L/opt/local/lib   access/SUBSYS.o bootstrap/SUBSYS.o catalog/SUBSYS.o parser/SUBSYS.o commands/SUBSYS.o executor/SUBSYS.o lib/SUBSYS.o libpq/SUBSYS.o main/SUBSYS.o nodes/SUBSYS.o optimizer/SUBSYS.o port/SUBSYS.o postmaster/SUBSYS.o regex/SUBSYS.o rewrite/SUBSYS.o storage/SUBSYS.o cop/SUBSYS.o utils/SUBSYS.o 
../../src/timezone/SUBSYS.o ../../src/port/libpgport_srv.a -lssl -lcrypto -lm -o postgres 
Undefined symbols: 
  "_PlannerInitPlan", referenced from: 
      _PlannerInitPlan$non_lazy_ptr in SUBSYS.o 
  "_strtable", referenced from: 
      _strtable$non_lazy_ptr in SUBSYS.o 
  "_base_yytext", referenced from: 
      _base_yytext$non_lazy_ptr in SUBSYS.o 
  "_PrivateRefCount", referenced from: 
      _PrivateRefCount$non_lazy_ptr in SUBSYS.o
ld: symbol(s) not found 
collect2: ld returned 1 exit status 
gnumake[2]: *** [postgres] Error 1 
gnumake[1]: *** [all] Error 2 
gnumake: *** [all] Error 2 
Error: Target org.macports.build returned: shell command " cd "/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_release_ports_databases_postgresql82/work/postgresql-8.2.5" && gnumake " returned error 2 

I solved this by downloading the original package from the PostgreSQL website. After that just untar the package, copy over the source and start the compilation again:


$ port install postgresql82 # Error occurs 
$ cd  /opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_release_ports_databases_postgresql82/work/postgresql-8.2.5
$ tar xjvf postgresql-8.2.5.tar.bz2 # (the downloaded package)
$ cp -rf postgresql-8.2.5/src/* src/
$ port install postgresql82 postgresql82-server

Setup PostgreSQL:


$ mkdir -p /opt/local/var/db/postgresql82/defaultdb
$ chown postgres:postgres /opt/local/var/db/postgresql82/defaultdb
$ su postgres -c '/opt/local/lib/postgresql82/bin/initdb -D /opt/local/var/db/postgresql82/defaultdb'
$ launchctl load -w /Library/LaunchDaemons/org.macports.postgresql82-server.plist

Hopefully the package maintainer will create a new package soon. In the mean time use this as fix.

UPDATE: the corresponding ticket of this bug can be found here
Also if you want to compile PostgreSQL with DTrace support take a look here

UPDATE 2: It seems grady.vincent found an easier solution. Thanks Chris for the notice! Here it is:


sudo port clean postgresql82
sudo port configure postgresql82
cd /opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_release_ports_databases_postgresql82/work/postgresql-8.2.5
make
sudo port install postgresql82
sudo port install postgresql82-server

Chris Abad

said Wednesday, 31 October 2007:

I tried twice and for some reason I still get this error:
http://pastie.caboo.se/112408


Jeffrey Gelens

said Wednesday, 31 October 2007:

You might take a look at the following site if you want to compile PostgreSQL with DTrace support: http://blog.invisible.ch/2007/10/28/rails-stack-on-leopard/ or http://leenux.org.uk/dtrace-patches/dtrace-with-postgres-on-osx/

My fix doesn’t include the fix for DTrace.


Marshall

said Monday, 05 November 2007:

I get the same error as Chris… any ideas?


Jeffrey Gelens

said Monday, 05 November 2007:

Like I said, try this URL: http://leenux.org.uk/dtrace-patches/dtrace-with-postgres-on-osx/


Chris

said Saturday, 17 November 2007:

#I got it working thanks to comment from grady.vincent
#http://trac.macosforge.org/projects/macports/ticket/12994

sudo port clean postgresql82
sudo port configure postgresql82
cd /opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_release_ports_databases_postgresql82/work/postgresql-8.2.5
make
sudo port install postgresql82
sudo port install postgresql82-server

#had issue cd’ing to the long path


Chris

said Sunday, 18 November 2007:

Not to confuse anyone but i think solution I got was a combination of downloading original source of postgresql82. You may have problems with macports in that you should change back to home directory (cd ~) after the make procedure.

Would love some help with how i use actually instigate a ‘createdb’ command by fixing PATH. macports does not seem to fix this. Are we expected to use full paths.
Other issue is how to know if server is running?
launchctl load -w /Library/LaunchDaemons/org.macports.postgresql82-server.plist
gives error as though server is running. but commands still do not work.


Russ Brooks

said Monday, 26 November 2007:

There is a much easier way to install PostgreSQL on OS X Leopard without using the MacPort or compiling yourself, and it maintains Apple’s established pathing conventions:
http://www2.russbrooks.com:8080/2007/11/4/install-postgresql-on-mac-os-x-10–5-leopard


Jeffrey Gelens

said Monday, 26 November 2007:

True, but a lot of people want to use a handy package manager like Macports or Fink to manage all installed software. One of the reasons can be that updates can be done easily. Another reason is that you can bulk install a lot of packages at the same time including the dependencies, that is impossible using standalone packages.


HazMatt

said Saturday, 01 December 2007:

I’ve followed all the tips above and I’m getting this error when I try to install postgresql82 on a Tiger server:

% sudo port install postgresql82

—-> Building postgresql82

Error: Target org.macports.build returned: shell command “cd /opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_release_ports_databases_postgresql82/work/postgresql-8.2.5/contrib/adminpack/ && {unset LD_PREBIND LD_PREBIND_ALLOW_OVERLAP && gnumake}” returned error 127

Command output: sh: line 1: {unset: command not found

Error: Status 1 encountered during processing.

Any ideas?


Jeffrey Gelens

said Saturday, 01 December 2007:

The above tips are for Leopard and not for Tiger. You could know that by reading the full article instead of only the shell commands.
Anyway, MacPorts is working fine with Tiger. Maybe you didn’t install Xcode or something because is missing some stuff. It is kinda strange though that it is missing “unset”. That command is kinda default I think.


Patriciaqz

said Wednesday, 26 March 2008:

nice work, man


Jeffrey Gelens

said Saturday, 05 April 2008:

It certainly is!


said on July 25, 2008:

(markup will be applied later)



said on July 25, 2008:


    ~ do cool stuff ~

Feeds

Latest Comments

Links

Blogroll

Gelens.org is powered by the latest Newforms-Admin branch of Django, running on Python 2.5.2 and served by Apache 2.2.8 with mod_wsgi 2.0c4, proxied by Nginx 0.6.31. The database is PostgreSQL 8.3.3. All of this is running on the latest ArchLinux on a 265MB Slicehost VPS.