Friday, May 4, 2007

mrbayes 3.1.2 readline errors

Compilation of MrBayes v 3.1.2 is failing on Mac with the version of readline that Apple ships. I get messages about rl_completion_matches being undeclared when compiling bayes.c and then get a link error because the symbol for rl_completion_matches is not found.

You can hand edit the Makefile to not use readline, for example by putting
USEREADLINE ?= no in place of USEREADLINE ?= yes but then you lose the handy tab completion.


I opted to add env sensitivity in place of:


ifeq ($(strip $(USEREADLINE)),yes)
CFLAGS += -DUSE_READLINE
LIBS += -lncurses -lreadline
endif


I used:


ifeq ($(strip $(USEREADLINE)),yes)
ifneq ($(READLINE_PREFIX), none)
CFLAGS += -I$(READLINE_PREFIX)/include
LIBS += -L$(READLINE_PREFIX)/lib -bind_at_load
endif
CFLAGS += -DUSE_READLINE
LIBS += -lncurses -lreadline
endif


then (in a bash shell) before invoking make, I issued the command:

export READLINE_PREFIX=/usr/local

because I have installed readline-5.2 under /usr/local on my machine.

I get multiple definition warnings about ncurses symbols _UP, _PC, and _BC, but it compiles, links, and the readline facilities do work.

No comments: