OrthoDB 1.6 Installation On Ubuntu 14.04 (And Related) – Build Errors And The Simple Fixes

UPDATE: 20 May 2016 – With thanks to OrthoDB's very own Fredrik Tegenfeldt, here's a more distro-complete fix for the Makefile.rules file.

# BRH flags
ifeq ($(USE_BRH),1)
BRH_DIR        = $(BASE_DIR)
CPPFLAGS    += -I$(BRH_DIR)/src
ifeq ($(WITH_RPATH),1)
LDFLAGS        += -L$(LIB_DIR) -Wl,-rpath,$(LIB_INSTDIR)
else
LDFLAGS        += -L$(LIB_DIR)
endif
LDLIBS        += -lbrh
endif

ifeq ($(USE_BOOST_THREAD),1)
CPPFLAGS    += -pthread -DHAS_BOOST_THREADS
LDFLAGS        += -pthread
LDLIBS      += -L$(DIR_BOOST_LIB) -lboost_system -L$(DIR_BOOST_THREAD) -l$(LIB_BOOST_THREAD) -lpthread
endif

And Happy New Year,

Yet another random Ubuntu-centric bioinformatics aside in the event others run into the same build issues (with errors included below, as you likely googled those first). For those wondering…

The Hierarchical Catalog of Orthologs v8

Orthology (website, download) is the cornerstone of comparative genomics and gene function prediction. OrthoDB aims to classify protein-coding genes from the increasing number of available sequenced genomes into groups of orthologs descended from a single gene of the last common ancestor (LCA) of each clade of species. Applying this concept to the hierarchy of LCAs along the species phylogeny results in multiple levels of orthology: the more closely-related the species, the more finely-resolved the orthologous relations.

The build here was on a fresh installation of 64-bit Ubuntu 14.04 (Trusty Tahr). All of the errors produced come from running on that clean install, meaning you'll run into dumb errors (like missing build-essential), didn't-know-we-needed-that errors (boost), and that's-probbly-an-Ubuntu-oddity errors (with a modified Makefile.rules file with explicit boost calls linked to below; I suspect the developers are working on a non-Ubuntu distro).

Relevant apt-get's

sudo apt-get install build-essential libboost-all-dev

Relevant Downloads

* tclap (1.2.1) – tclap.sourceforge.net/

Stage 1 – Just Trying The Easy Install

I build everything in /opt by default and propose you do the same (whatever). First steps included.

username@ubuntu:~$ cd Downloads/
username@ubuntu:~/Downloads$ sudo mv OrthoDB_soft_1.6.tgz /opt/
username@ubuntu:~/Downloads$ cd /opt/
username@ubuntu:/opt$ sudo tar xvf OrthoDB_soft_1.6.tgz 

OrthoDB_soft_1.6/
OrthoDB_soft_1.6/BRHCLUS-1.12.7/
...
OrthoDB_soft_1.6/README
OrthoDB_soft_1.6/LICENSE
username@ubuntu:/opt$ cd OrthoDB_soft_1.6/
username@ubuntu:/opt/OrthoDB_soft_1.6$ sudo make WITH_RPATH=1 prefix=$(pwd) all
make: *** No rule to make target `all'.  Stop.

If you read the README file, you figure out to move to the BRHCLUS folder, then discover the need for the boost libraries, available via an apt-get:

username@ubuntu:/opt/OrthoDB_soft_1.6$ cd BRHCLUS-1.12.7/
username@ubuntu:/opt/OrthoDB_soft_1.6/BRHCLUS-1.12.7$ sudo ./configure.sh 
FATAL: cannot find boost libraries!
- Is boost installed (boost_system) ?
- Is boost installed in any of the search paths ?
  If not, add the path to PATH_SEARCH_LIB at the top of this script.

Stage 2 – sudo apt-get install libboost-all-dev

username@ubuntu:/opt/OrthoDB_soft_1.6/BRHCLUS-1.12.7$ sudo apt-get install libboost-all-dev 
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following packages were automatically installed and are no longer required:
  account-plugin-windows-live libupstart1
Use 'apt-get autoremove' to remove them.
The following extra packages will be installed:
  icu-devtools libboost-atomic-dev libboost-atomic1.54-dev
  libboost-atomic1.54.0 libboost-chrono-dev libboost-chrono1.54-dev
...
  libxml2-dev mpi-default-bin mpi-default-dev ocl-icd-libopencl1 openmpi-bin
  openmpi-common zlib1g-dev
0 upgraded, 102 newly installed, 0 to remove and 14 not upgraded.
Need to get 46.7 MB of archives.
After this operation, 262 MB of additional disk space will be used.
Do you want to continue? [Y/n] 
Get:1 http://us.archive.ubuntu.com/ubuntu/ trusty-updates/main libboost-atomic1.54.0 amd64 1.54.0-4ubuntu3.1 [8,076 B]
Get:2 http://us.archive.ubuntu.com/ubuntu/ trusty-updates/main libboost-chrono1.54.0 amd64 1.54.0-4ubuntu3.1 [12.5 kB]
Get:3 http://us.archive.ubuntu.com/ubuntu/ trusty-updates/universe libboost-context1.54.0 amd64 1.54.0-4ubuntu3.1 [8,028 B]
Get:4 http://us.archive.ubuntu.com/ubuntu/ trusty-updates/main libboost-filesystem1.54.0 amd64 1.54.0-4ubuntu3.1 [34.2 kB]
...
Setting up libboost-wave-dev:amd64 (1.54.0.1ubuntu1) ...
Setting up libboost-all-dev (1.54.0.1ubuntu1) ...
Setting up libhwloc-plugins (1.8-1ubuntu1.14.04.1) ...
Processing triggers for libc-bin (2.19-0ubuntu6.6) ...

The configure stage now works…

username@ubuntu:/opt/OrthoDB_soft_1.6/BRHCLUS-1.12.7$ sudo ./configure.sh 
OK - boost libraries
OK - boost thread libraries
OK - boost include dir
OK - tclap include dir
OK - thread pool include dir
Config file (/opt/OrthoDB_soft_1.6/BRHCLUS-1.12.7/Makefile.config) successfully created

But, right off the bat, a clean install is missing build tools.

username@ubuntu:/opt/OrthoDB_soft_1.6/BRHCLUS-1.12.7$ sudo make WITH_RPATH=1 prefix=$(pwd) all
  Compiling brh_version.cpp
/bin/sh: 1: g++: not found
make[2]: *** [.linux/brh_version.o] Error 127
make[1]: *** [src] Error 2
make: *** [all] Error 2

Stage 3 – sudo apt-get install build-essential

username@ubuntu:/opt/OrthoDB_soft_1.6/BRHCLUS-1.12.7$ sudo apt-get install build-essential 
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following packages were automatically installed and are no longer required:
  account-plugin-windows-live libupstart1
...
0 upgraded, 9 newly installed, 0 to remove and 14 not upgraded.
Need to get 15.9 MB of archives.
After this operation, 27.9 MB of additional disk space will be used.
Do you want to continue? [Y/n] 
Get:1 http://us.archive.ubuntu.com/ubuntu/ trusty-updates/main g++-4.8 amd64 4.8.4-2ubuntu1~14.04 [15.0 MB]
Get:2 http://us.archive.ubuntu.com/ubuntu/ trusty/main g++ amd64 4:4.8.2-1ubuntu6 [1,490 B]
Get:3 http://us.archive.ubuntu.com/ubuntu/ trusty-updates/main dpkg-dev all 1.17.5ubuntu5.5 [726 kB]
Get:4 http://us.archive.ubuntu.com/ubuntu/ trusty/main build-essential amd64 11.6ubuntu6 [4,838 B]
...
update-alternatives: using /usr/bin/fakeroot-sysv to provide /usr/bin/fakeroot (fakeroot) in auto mode
Setting up libalgorithm-diff-perl (1.19.02-3) ...
Setting up libalgorithm-diff-xs-perl (0.04-2build4) ...
Setting up libalgorithm-merge-perl (0.08-2) ...

And the build process now takes steps forward.

username@ubuntu:/opt/OrthoDB_soft_1.6/BRHCLUS-1.12.7$ sudo make WITH_RPATH=1 prefix=$(pwd) all
  Compiling brh_version.cpp
  Compiling brh_common.cpp
  Compiling pairdataset.cpp
  Compiling brh_functions.cpp
  Compiling keymap.cpp
  Compiling inparalog.cpp
  Compiling clusterdata.cpp
  Compiling cluster.cpp
  Compiling clusterize.cpp
  Compiling cluster_functions.cpp
  Compiling modularity.cpp
  Compiling tri4algo.cpp
  Linking libbrh.so
  Compiling brhclus.cpp
  Linking brhclus
.linux/brhclus.o: In function `__static_initialization_and_destruction_0':
/usr/include/boost/system/error_code.hpp:222: undefined reference to `boost::system::generic_category()'
/usr/include/boost/system/error_code.hpp:223: undefined reference to `boost::system::generic_category()'
/usr/include/boost/system/error_code.hpp:224: undefined reference to `boost::system::system_category()'
/opt/OrthoDB_soft_1.6/BRHCLUS-1.12.7/lib/libbrh.so: undefined reference to `boost::detail::get_current_thread_data()'
/opt/OrthoDB_soft_1.6/BRHCLUS-1.12.7/lib/libbrh.so: undefined reference to `boost::this_thread::disable_interruption::disable_interruption()'
/opt/OrthoDB_soft_1.6/BRHCLUS-1.12.7/lib/libbrh.so: undefined reference to `boost::this_thread::interruption_point()'
/opt/OrthoDB_soft_1.6/BRHCLUS-1.12.7/lib/libbrh.so: undefined reference to `boost::thread::start_thread_noexcept()'
/opt/OrthoDB_soft_1.6/BRHCLUS-1.12.7/lib/libbrh.so: undefined reference to `boost::thread::interrupt()'
/opt/OrthoDB_soft_1.6/BRHCLUS-1.12.7/lib/libbrh.so: undefined reference to `boost::this_thread::hiden::sleep_until(timespec const&)'
/opt/OrthoDB_soft_1.6/BRHCLUS-1.12.7/lib/libbrh.so: undefined reference to `boost::thread::join_noexcept()'
/opt/OrthoDB_soft_1.6/BRHCLUS-1.12.7/lib/libbrh.so: undefined reference to `vtable for boost::detail::thread_data_base'
/opt/OrthoDB_soft_1.6/BRHCLUS-1.12.7/lib/libbrh.so: undefined reference to `boost::detail::thread_data_base::~thread_data_base()'
/opt/OrthoDB_soft_1.6/BRHCLUS-1.12.7/lib/libbrh.so: undefined reference to `boost::thread::native_handle()'
/opt/OrthoDB_soft_1.6/BRHCLUS-1.12.7/lib/libbrh.so: undefined reference to `boost::thread::detach()'
/opt/OrthoDB_soft_1.6/BRHCLUS-1.12.7/lib/libbrh.so: undefined reference to `boost::this_thread::disable_interruption::~disable_interruption()'
/opt/OrthoDB_soft_1.6/BRHCLUS-1.12.7/lib/libbrh.so: undefined reference to `typeinfo for boost::detail::thread_data_base'
collect2: error: ld returned 1 exit status
make[2]: *** [/opt/OrthoDB_soft_1.6/BRHCLUS-1.12.7/bin/brhclus] Error 1
make[1]: *** [tools/brhclus] Error 2
make: *** [all] Error 2

Stage 4 – tclap Install

A quick google search produces the following from info.circ.rochester.edu/BlueHive/Software/Bioinformatics/orthodb.html indicating that tclap is an OrthoDB dependency that needs to be satisfied. The version I've built below (1.2.1) can be downloaded from tclap.sourceforge.net

username@ubuntu:/opt$ ls
OrthoDB_soft_1.6  OrthoDB_soft_1.6.tgz  tclap-1.2.1.tar.gz

Extract and expand.

username@ubuntu:/opt$ sudo tar xvf tclap-1.2.1.tar.gz 
tclap-1.2.1/
tclap-1.2.1/aclocal.m4
tclap-1.2.1/AUTHORS
tclap-1.2.1/ChangeLog
...
tclap-1.2.1/config/Makefile.am
tclap-1.2.1/config/Makefile.in
tclap-1.2.1/config/missing
tclap-1.2.1/config/mkinstalldirs

The build process goes without issue.

username@ubuntu:/opt$ cd tclap-1.2.1/
username@ubuntu:/opt/tclap-1.2.1$ sudo ./configure 
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for a thread-safe mkdir -p... /bin/mkdir -p
checking for gawk... no
checking for mawk... mawk
...
config.status: creating tests/Makefile
config.status: creating config/config.h
config.status: executing depfiles commands
config.status: executing default commands

Onto make…

username@ubuntu:/opt/tclap-1.2.1$ sudo make
Making all in include
make[1]: Entering directory `/opt/tclap-1.2.1/include'
Making all in tclap
make[2]: Entering directory `/opt/tclap-1.2.1/include/tclap'
make[2]: Nothing to be done for `all'.
...
make[1]: Leaving directory `/opt/tclap-1.2.1/config'
make[1]: Entering directory `/opt/tclap-1.2.1'
make[1]: Nothing to be done for `all-am'.
make[1]: Leaving directory `/opt/tclap-1.2.1'

And make install…

username@ubuntu:/opt/tclap-1.2.1$ sudo make install
Making install in include
make[1]: Entering directory `/opt/tclap-1.2.1/include'
Making install in tclap
make[2]: Entering directory `/opt/tclap-1.2.1/include/tclap'
...
test -z "/usr/local/lib/pkgconfig" || /bin/mkdir -p "/usr/local/lib/pkgconfig"
 /usr/bin/install -c -m 644 'tclap.pc' '/usr/local/lib/pkgconfig/tclap.pc'
make[2]: Leaving directory `/opt/tclap-1.2.1'
make[1]: Leaving directory `/opt/tclap-1.2.1'

Stage 5 – Re-attempt The OrthoDB Build

The configure goes without issue again…

username@ubuntu:/opt$ cd OrthoDB_soft_1.6/
username@ubuntu:/opt/OrthoDB_soft_1.6$ cd BRHCLUS-1.12.7/
username@ubuntu:/opt/OrthoDB_soft_1.6/BRHCLUS-1.12.7$ sudo make clean
username@ubuntu:/opt/OrthoDB_soft_1.6/BRHCLUS-1.12.7$ sudo ./configure.sh 
OK - boost libraries
OK - boost thread libraries
OK - boost include dir
OK - tclap include dir
OK - thread pool include dir
Config file (/opt/OrthoDB_soft_1.6/BRHCLUS-1.12.7/Makefile.config) successfully created

But there's still an error at the make stage.

username@ubuntu:/opt/OrthoDB_soft_1.6/BRHCLUS-1.12.7$ sudo make all
  Compiling brh_version.cpp
  Compiling brh_common.cpp
  Compiling pairdataset.cpp
  Compiling brh_functions.cpp
  Compiling keymap.cpp
  Compiling inparalog.cpp
  Compiling clusterdata.cpp
  Compiling cluster.cpp
  Compiling clusterize.cpp
  Compiling cluster_functions.cpp
  Compiling modularity.cpp
  Compiling tri4algo.cpp
  Linking libbrh.so
  Compiling brhclus.cpp
  Linking brhclus
.linux/brhclus.o: In function `__static_initialization_and_destruction_0':
/usr/include/boost/system/error_code.hpp:222: undefined reference to `boost::system::generic_category()'
/usr/include/boost/system/error_code.hpp:223: undefined reference to `boost::system::generic_category()'
/usr/include/boost/system/error_code.hpp:224: undefined reference to `boost::system::system_category()'
/opt/OrthoDB_soft_1.6/BRHCLUS-1.12.7/lib/libbrh.so: undefined reference to `boost::detail::get_current_thread_data()'
/opt/OrthoDB_soft_1.6/BRHCLUS-1.12.7/lib/libbrh.so: undefined reference to `boost::this_thread::disable_interruption::disable_interruption()'
/opt/OrthoDB_soft_1.6/BRHCLUS-1.12.7/lib/libbrh.so: undefined reference to `boost::this_thread::interruption_point()'
/opt/OrthoDB_soft_1.6/BRHCLUS-1.12.7/lib/libbrh.so: undefined reference to `boost::thread::start_thread_noexcept()'
/opt/OrthoDB_soft_1.6/BRHCLUS-1.12.7/lib/libbrh.so: undefined reference to `boost::thread::interrupt()'
/opt/OrthoDB_soft_1.6/BRHCLUS-1.12.7/lib/libbrh.so: undefined reference to `boost::this_thread::hiden::sleep_until(timespec const&)'
/opt/OrthoDB_soft_1.6/BRHCLUS-1.12.7/lib/libbrh.so: undefined reference to `boost::thread::join_noexcept()'
/opt/OrthoDB_soft_1.6/BRHCLUS-1.12.7/lib/libbrh.so: undefined reference to `vtable for boost::detail::thread_data_base'
/opt/OrthoDB_soft_1.6/BRHCLUS-1.12.7/lib/libbrh.so: undefined reference to `boost::detail::thread_data_base::~thread_data_base()'
/opt/OrthoDB_soft_1.6/BRHCLUS-1.12.7/lib/libbrh.so: undefined reference to `boost::thread::native_handle()'
/opt/OrthoDB_soft_1.6/BRHCLUS-1.12.7/lib/libbrh.so: undefined reference to `boost::thread::detach()'
/opt/OrthoDB_soft_1.6/BRHCLUS-1.12.7/lib/libbrh.so: undefined reference to `boost::this_thread::disable_interruption::~disable_interruption()'
/opt/OrthoDB_soft_1.6/BRHCLUS-1.12.7/lib/libbrh.so: undefined reference to `typeinfo for boost::detail::thread_data_base'
collect2: error: ld returned 1 exit status
make[2]: *** [/opt/OrthoDB_soft_1.6/BRHCLUS-1.12.7/bin/brhclus] Error 1
make[1]: *** [tools/brhclus] Error 2
make: *** [all] Error 2

Stage 6 – Google Says Make Some Symbolic Links

A first fix for the boost error was to make symbolic links for libboost_thread.so and libboost_timer.so in /usr/lib.

username@ubuntu:/opt/OrthoDB_soft_1.6/BRHCLUS-1.12.7$ cd /usr/lib/x86_64-linux-gnu/
username@ubuntu:/usr/lib/x86_64-linux-gnu$ sudo ln -s libboost_thread.so /usr/lib
username@ubuntu:/usr/lib/x86_64-linux-gnu$ sudo ln -s libboost_timer.so /usr/lib
username@ubuntu:/usr/lib/x86_64-linux-gnu$ cd /opt/OrthoDB_soft_1.6/BRHCLUS-1.12.7/
username@ubuntu:/opt/OrthoDB_soft_1.6/BRHCLUS-1.12.7$ sudo make clean
username@ubuntu:/opt/OrthoDB_soft_1.6/BRHCLUS-1.12.7$ sudo ./configure.sh 
OK - boost libraries
OK - boost thread libraries
OK - boost include dir
OK - tclap include dir
OK - thread pool include dir
Config file (/opt/OrthoDB_soft_1.6/BRHCLUS-1.12.7/Makefile.config) successfully created

But this didn't work either.

username@ubuntu:/opt/OrthoDB_soft_1.6/BRHCLUS-1.12.7$ sudo make all
  Compiling brh_version.cpp
  Compiling brh_common.cpp
  Compiling pairdataset.cpp
  Compiling brh_functions.cpp
  Compiling keymap.cpp
  Compiling inparalog.cpp
  Compiling clusterdata.cpp
  Compiling cluster.cpp
  Compiling clusterize.cpp
  Compiling cluster_functions.cpp
  Compiling modularity.cpp
  Compiling tri4algo.cpp
  Linking libbrh.so
  Compiling brhclus.cpp
  Linking brhclus
.linux/brhclus.o: In function `__static_initialization_and_destruction_0':
/usr/include/boost/system/error_code.hpp:222: undefined reference to `boost::system::generic_category()'
/usr/include/boost/system/error_code.hpp:223: undefined reference to `boost::system::generic_category()'
/usr/include/boost/system/error_code.hpp:224: undefined reference to `boost::system::system_category()'
/opt/OrthoDB_soft_1.6/BRHCLUS-1.12.7/lib/libbrh.so: undefined reference to `boost::detail::get_current_thread_data()'
/opt/OrthoDB_soft_1.6/BRHCLUS-1.12.7/lib/libbrh.so: undefined reference to `boost::this_thread::disable_interruption::disable_interruption()'
/opt/OrthoDB_soft_1.6/BRHCLUS-1.12.7/lib/libbrh.so: undefined reference to `boost::this_thread::interruption_point()'
/opt/OrthoDB_soft_1.6/BRHCLUS-1.12.7/lib/libbrh.so: undefined reference to `boost::thread::start_thread_noexcept()'
/opt/OrthoDB_soft_1.6/BRHCLUS-1.12.7/lib/libbrh.so: undefined reference to `boost::thread::interrupt()'
/opt/OrthoDB_soft_1.6/BRHCLUS-1.12.7/lib/libbrh.so: undefined reference to `boost::this_thread::hiden::sleep_until(timespec const&)'
/opt/OrthoDB_soft_1.6/BRHCLUS-1.12.7/lib/libbrh.so: undefined reference to `boost::thread::join_noexcept()'
/opt/OrthoDB_soft_1.6/BRHCLUS-1.12.7/lib/libbrh.so: undefined reference to `vtable for boost::detail::thread_data_base'
/opt/OrthoDB_soft_1.6/BRHCLUS-1.12.7/lib/libbrh.so: undefined reference to `boost::detail::thread_data_base::~thread_data_base()'
/opt/OrthoDB_soft_1.6/BRHCLUS-1.12.7/lib/libbrh.so: undefined reference to `boost::thread::native_handle()'
/opt/OrthoDB_soft_1.6/BRHCLUS-1.12.7/lib/libbrh.so: undefined reference to `boost::thread::detach()'
/opt/OrthoDB_soft_1.6/BRHCLUS-1.12.7/lib/libbrh.so: undefined reference to `boost::this_thread::disable_interruption::~disable_interruption()'
/opt/OrthoDB_soft_1.6/BRHCLUS-1.12.7/lib/libbrh.so: undefined reference to `typeinfo for boost::detail::thread_data_base'
collect2: error: ld returned 1 exit status
make[2]: *** [/opt/OrthoDB_soft_1.6/BRHCLUS-1.12.7/bin/brhclus] Error 1
make[1]: *** [tools/brhclus] Error 2
make: *** [all] Error 2

Stage 7 – The Boost Issue May Be Ubuntu-Specific

The final solution was to modify the Makefile.rules file to explicitly call on boost in Ubuntu. Make a backup copy of the Makefile.rules in the OrthoDB folder, then place this new Makefile.rules file into the same folder. The modified Makefile.rules is below for copy+paste, else you can download it here: 2016mar25_orthodb_Makefile_rules.txt (just rename the file and place into OrthoDB_soft_1.6/BRHCLUS-1.12.7).

username@ubuntu:/opt/OrthoDB_soft_1.6/BRHCLUS-1.12.7$ sudo nano Makefile.rules 
#
# Build rules
#

# Keep secondary files
.SECONDARY:

include $(ROOT_DIR)/Makefile.config
ifeq ($(strip $(DIR_TCLAP)),)
$(error "Build requires TCLAP package (http://tclap.sourceforge.net)")
endif

# if install, read build details
ifeq "$(MAKE-TARGET)" "install"
include $(ROOT_DIR)/.makefile.build
endif

# Object directory
OBJ_DIR		= .linux

# Use gcc4
CXX		= g++

# Use rpath or not
WITH_RPATH	?= 1

LDFLAGS		= 
ifeq "$(MAKE-TARGET)" "static"
WITH_RPATH	= 0
LDFLAGS		+= -static -lboost_system -lboost_thread -lpthread
endif

# check BOOST
USE_BOOST ?= 1

# check boost threads
USE_BOOST_THREAD ?= 1

ifeq ($(strip $(LIB_BOOST_THREAD)),)
USE_BOOST_THREAD = 0
USE_THREADPOOL = 0
endif

ifeq ($(strip $(DIR_THREADPOOL)),)
USE_THREADPOOL = 0
endif

# Library and binary directories
BASE_DIR	:= $(shell cd $(ROOT_DIR) ; pwd)

# Install directories
# With rpath, enforce install dir same as build
# Without, use same as build as default
# prefix - install topdir
# libdir/bindir - install lib/bin
# BASE_DIR - build top dir
# LIB_DIR/BIN_DIR - build top dir
#
# with rpath :
#   build and install dirs are the same
#   default top is BASE_DIR
# else :
#   build is always under BASE_DIR
#   install under prefix (default BASE_DIR)
#
#ifeq ($(WITH_RPATH),1)
#prefix		?= $(BASE_DIR)
#libdir		= $(prefix)/lib
#bindir		= $(prefix)/bin
##LIB_DIR		:= $(shell mkdir -p $(libdir) ; cd $(libdir) ; pwd)
##BIN_DIR		:= $(shell mkdir -p $(bindir) ; cd $(bindir) ; pwd)
#LIB_DIR		:= $(libdir)
#BIN_DIR		:= $(bindir)
#else
#LIB_DIR		:= $(shell mkdir -p $(BASE_DIR)/lib ; cd $(BASE_DIR)/lib ; pwd)
#BIN_DIR		:= $(shell mkdir -p $(BASE_DIR)/bin ; cd $(BASE_DIR)/bin ; pwd)
#prefix		?= $(BASE_DIR)
#libdir		?= $(LIB_DIR)
#bindir		?= $(BIN_DIR)
#endif
LIB_DIR		:= $(shell mkdir -p $(BASE_DIR)/lib ; cd $(BASE_DIR)/lib ; pwd)
BIN_DIR		:= $(shell mkdir -p $(BASE_DIR)/bin ; cd $(BASE_DIR)/bin ; pwd)
prefix		?= $(BASE_DIR)
libdir		?= $(LIB_DIR)
bindir		?= $(BIN_DIR)
LIB_INSTDIR := $(prefix)/lib
BIN_INSTDIR := $(prefix)/bin

# Install user/group
INST_USR	 = $(shell whoami)
INST_GRP	?= $(shell groups | cut -f 1 -d ' ' )

# Establish install command
# if rpath -> always chown
# else
#   if targetdir==installdir -> chown
#   else install
# endif
#ifeq ($(WITH_RPATH),1)
#INST_CMD	 = chown $(INST_USR).$(INST_GRP)
#else
TARGET_DIR	= $(dir $(TARGET))
rpTARGET	= $(realpath $(firstword $(TARGET_DIR)))
rpINSTDIR	= $(realpath $(prefix)/$(INSTDIR))
ifeq ($(rpTARGET),$(rpINSTDIR))
INST_CMD	 = chown $(INST_USR).$(INST_GRP)
else
INST_CMD	 = mkdir -p $(prefix)/$(INSTDIR); install -D -m 755 -g $(INST_GRP) -t $(prefix)/$(INSTDIR)
endif
#endif

# Definitions concerning build environment
CPPFLAGS	+= -DBRH_BUILD_ENV="\"$(shell uname -s -r -v -m -i -p -o)\""
CPPFLAGS	+= -DBRH_BUILD_TIME="\"$(shell date)\""

# Default pre-processor flags
CPPFLAGS	+= -DBASE_DIR="\"$(BASE_DIR)\""
CPPFLAGS	+= -D_REENTRANT
CPPFLAGS	+= -D_XOPEN_SOURCE

# c++ standard
CPPFLAGS	+= -std=c++11
CXXFLAGS	+= -std=c++11

# debug flag
ifeq ($(USE_DEBUG),3)
CXXFLAGS	+= -fno-inline -fbounds-check
else ifeq ($(USE_DEBUG),2)
CPPFLAGS	+= -DBRH_DEBUG
CXXFLAGS	+= -fno-inline -fbounds-check
else ifeq ($(USE_DEBUG),1)
CPPFLAGS	+= -DBRH_CHECK_IT
CXXFLAGS	+= -finline-functions -fbounds-check
else
CXXFLAGS	+= -finline-functions
endif

# Default compiler flags
CXXFLAGS	+= -fPIC
CXXFLAGS	+= -MMD
CXXFLAGS	+= -g
CXXFLAGS	+= -Wall -Werror
CXXFLAGS	+= -fexceptions
#CXXFLAGS	+= -fno-inline
CXXFLAGS	+= -O3
#CXXFLAGS	+= -O0
CXXFLAGS	+= -I$(BASE_DIR)/src
#CXXFLAGS	+= -std=c++11
#CXXFLAGS	+= -pg
#LDFLAGS		+= -pg

# BRH flags
ifeq ($(USE_BRH),1)
BRH_DIR		= $(BASE_DIR)
CPPFLAGS	+= -I$(BRH_DIR)/src
ifeq ($(WITH_RPATH),1)
LDFLAGS		+= -L$(LIB_DIR) -Wl,-rpath,$(LIB_INSTDIR) -lboost_system -lboost_thread -lpthread
else
LDFLAGS		+= -L$(LIB_DIR) -lboost_system -lboost_thread -lpthread
endif
LDLIBS		+= -lbrh -lboost_system -lboost_thread -lpthread
endif

ifeq ($(USE_BOOST_THREAD),1)
CPPFLAGS	+= -pthread -DHAS_BOOST_THREADS
LDFLAGS		+= -pthread -L$(DIR_BOOST_LIB) -lboost_system -lboost_thread -lpthread -L$(DIR_BOOST_THREAD) -l$(LIB_BOOST_THREAD)
endif

ifeq ($(USE_THREADPOOL),1)
CPPFLAGS	+= -DHAS_BOOST_THREADPOOL
CPPFLAGS	+= -I$(DIR_THREADPOOL)
endif

ifeq ($(USE_BOOST),1)
CPPFLAGS	+= -I$(DIR_BOOST_INC)
endif

# TCLAP flags
ifeq ($(USE_TCLAP),1)
CPPFLAGS	+= -I$(DIR_TCLAP)
endif

# BOOST flags
ifeq ($(USE_THREAD),1)
endif

# Check file type
ifeq ($(suffix $(firstword $(SOURCES))),.cpp)
IS_CPP		= 1
else
IS_CPP		= 0
endif

# List of objects
ifeq ($(IS_CPP),1)
OBJECTS		= $(SOURCES:%.cpp=$(OBJ_DIR)/%.o)
endif

# Default build
default:	all

ifeq ($(IS_CPP),1)
# Build a binary
$(BIN_DIR)/%: $(OBJECTS) Makefile $(BASE_DIR)/Makefile.rules
	@echo "  Linking $(@F)"
	@mkdir -p $(@D)
	@$(LINK.cc) $(LDFLAGS) -o $@ $(OBJECTS) $(LDLIBS)

# Build a shared library
$(LIB_DIR)/%.so: $(OBJECTS) Makefile $(BASE_DIR)/Makefile.rules
	@echo "  Linking $(@F)"
	@mkdir -p $(@D)
	@$(LINK.cc) -shared -o $@ $(OBJECTS) $(LDLIBS)

# Build a static library
$(LIB_DIR)/%.a: $(OBJECTS) Makefile $(BASE_DIR)/Makefile.rules
	@echo "  Linking $(@F)"
	@mkdir -p $(@D)
	@ar rcs $@ $(OBJECTS)

# Include dependency files
-include $(OBJECTS:%.o=%.d)

# Build an object file
$(OBJ_DIR)/%.o: %.cpp Makefile
	@echo "  Compiling $< "
	@mkdir -p $(@D)
	@$(COMPILE.cc) -o $@ $<
else
$(BIN_DIR)/%.py: %.py
	@echo "  Copying $< to target dir"
	@cp -f $< $@
endif



# Main targets are phony
.PHONY: default all clean_target clean_obj doc clean_doc clean install static

# Build target
all:	$(TARGET)

static:	$(TARGET)

# Clean objects
clean_obj:
	@$(RM) -r $(OBJ_DIR)

# Clean build
clean_target:
	@$(RM) -r $(OBJ_DIR) $(TARGET)

# Build documentation
doc:
	@$(MAKE) -C $(BASE_DIR) $@

# Clean build
clean: clean_target

# Install
install:
#	@echo "rpT   : $(rpTARGET)"
#	@echo "rpI   : $(rpINSTDIR)"
#	@echo "rpath : $(WITH_RPATH)"
#	@echo "inst  : $(INST_CMD) $(TARGET)"
	@target="$(TARGET)"; \
	[ $${#target} -gt 0 ] || target="$(OUTPUT)"; \
	for f in $${target}; do \
	    fname=`basename $$f`; \
	    if [ -f $$f ]; then \
	       echo "Installing in $(prefix)/$(INSTDIR)    <$$fname>"; \
	       $(INST_CMD) $$f; \
	    fi; \
	done

The configure step runs fine…

username@ubuntu:/opt/OrthoDB_soft_1.6/BRHCLUS-1.12.7$ sudo make clean
username@ubuntu:/opt/OrthoDB_soft_1.6/BRHCLUS-1.12.7$ sudo ./configure.sh 
OK - boost libraries
OK - boost thread libraries
OK - boost include dir
OK - tclap include dir
OK - thread pool include dir
Config file (/opt/OrthoDB_soft_1.6/BRHCLUS-1.12.7/Makefile.config) successfully created

…and the build itself runs fine.

username@ubuntu:/opt/OrthoDB_soft_1.6/BRHCLUS-1.12.7$ sudo make all
  Compiling brh_version.cpp
  Compiling brh_common.cpp
  Compiling pairdataset.cpp
  Compiling brh_functions.cpp
  Compiling keymap.cpp
  Compiling inparalog.cpp
  Compiling clusterdata.cpp
  Compiling cluster.cpp
  Compiling clusterize.cpp
  Compiling cluster_functions.cpp
  Compiling modularity.cpp
  Compiling tri4algo.cpp
  Linking libbrh.so
  Compiling brhclus.cpp
  Linking brhclus
  Compiling evolrate.cpp
  Linking evolrate
  Compiling statbrh.cpp
  Linking statbrh
  Compiling brh2x.cpp
  Linking brh2x
  Compiling statclus.cpp
  Linking statclus
  Compiling cmpclus.cpp
  Linking cmpclus
  Compiling getclus.cpp
  Linking getclus
  Compiling cmpbrh.cpp
  Linking cmpbrh
  Compiling cmpinpar.cpp
  Linking cmpinpar
  Compiling renumclus.cpp
  Linking renumclus
  Compiling getinpar.cpp
  Linking getinpar
  Compiling mergeinpar.cpp
  Linking mergeinpar
  Compiling align2brh.cpp
  Linking align2brh
  Compiling findbrh.cpp
  Linking findbrh
  Copying parsedump.py to target dir
  Copying getbrh.py to target dir
  Copying plot_brhclus_progress.py to target dir

Stage 8 – Build The Tests

Just to make sure all is working, make globaltest.

username@ubuntu:/opt/OrthoDB_soft_1.6/BRHCLUS-1.12.7$ sudo make globaltest 

-------------------------------------------------------------
Binary  dir : /opt/OrthoDB_soft_1.6/BRHCLUS-1.12.7/bin
Library dir : /opt/OrthoDB_soft_1.6/BRHCLUS-1.12.7/lib
-------------------------------------------------------------

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
TEST MACHINE
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
uname [ Linux ubuntux 3.16.0-59-generic #79~14.04.1-Ubuntu SMP Mon Jan 18 15:41:27...]
cpu   [ Intel(R) Core(TM) i7-3930K CPU @ 3.20GHz]
mem   [ MemTotal:        3949740 kB]

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
TEST BRHCLUS
with option --single
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
------------------------------
run default setup
------------------------------
------------------------------
run with harder e-value cuts
------------------------------
------------------------------
run with soft e-value cuts
------------------------------
------------------------------
Check output files
------------------------------
default                                [OK]
hard_e-val                             [OK]
soft_e-val                             [OK]
------------------------------
Check timing
------------------------------
default                                [16 %]
hard_e-val                             [-8 %]
soft_e-val                             [10 %]

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
TEST BRHCLUS, resume function
with option --single
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
resume                                 [OK, contents same but clids or seqs differ]

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
TEST BRHCLUS
with option --nostringent
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
------------------------------
run default setup
------------------------------
------------------------------
run with harder e-value cuts
------------------------------
------------------------------
run with soft e-value cuts
------------------------------
------------------------------
Check output files
------------------------------
default                                [OK]
hard_e-val                             [OK]
soft_e-val                             [OK]
------------------------------
Check timing
------------------------------
default                                [18 %]
hard_e-val                             [10 %]
soft_e-val                             [2 %]

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
TEST BRHCLUS, resume function
with option --nostringent
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
resume                                 [OK, contents same but clids or seqs differ]

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
TEST BRHCLUS
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
------------------------------
run default setup
------------------------------
------------------------------
run with harder e-value cuts
------------------------------
------------------------------
run with soft e-value cuts
------------------------------
------------------------------
Check output files
------------------------------
default                                [OK]
hard_e-val                             [OK]
soft_e-val                             [OK]
------------------------------
Check timing
------------------------------
default                                [7 %]
hard_e-val                             [8 %]
soft_e-val                             [12 %]

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
TEST BRHCLUS, resume function
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
resume                                 [OK, contents same but clids or seqs differ]

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
TEST BRHCLUS
with option --lowmem
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
------------------------------
run default setup
------------------------------
------------------------------
run with harder e-value cuts
------------------------------
------------------------------
run with soft e-value cuts
------------------------------
------------------------------
Check output files
------------------------------
default                                [OK]
hard_e-val                             [OK]
soft_e-val                             [OK]
------------------------------
Check timing
------------------------------
default                                [6 %]
hard_e-val                             [8 %]
soft_e-val                             [7 %]

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
TEST BRHCLUS, resume function
with option --lowmem
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
resume                                 [OK, contents same but clids or seqs differ]

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
TEST BRHCLUS
merge BRHs into an existing cluster configuration
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
mergebrh                               [OK]

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
TEST STATCLUS
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
default                                [OK]
hard_e-val                             [OK]
soft_e-val                             [OK]

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
TEST CMPCLUS
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
exact_match                            [OK]
mis-match                              [OK]

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
TEST CMPCLUS
related groups
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
default                                [OK]

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
TEST MERGEINPAR
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
clusters                               [OK]
unresolved                             [OK]


------------------------------------------
Warnings (4) were detected.
------------------------------------------

Most likely this is of not concern and the probable origin are messages like

  [OK, contents same but clids or seqs differ]

They may be caused by rounding errors on different architectures/versions of the software.

GROMACS 5.0.1, nVidia CUDA Toolkit, And FFTW3 Under Ubuntu 14.04 LTS (64-bit); The Virtues Of VirtualBox

Summarized below are the catches and fixes from a recent effort to build GROMACS 5.0.1 with FFTW3 (single- and double-precision) and GPU support (so, single-precision). Also, a trick I've been doing with great success lately, using a virtual machine to keep my real machine as clean as possible.

0. The Virtues Of VirtualBox

Open source means never having to say you're sorry.

I've made the above proclamation to anyone who'd listen lately who has any interest in using Linux software (because, regardless of what anyone says on the matter, it ain't there yet as an operating system for general scientific users with general computing know-how). You will very likely find yourself stuck at a configure or make step in one or more prerequisite codes to some final build you're trying to do, leaving yourself to google error messages to try to come up with some kind of solution. Invariably, you'll try something that seems to work, only to find it doesn't, potentially leaving a trail of orphaned files, version-breaking changes, and random downgrading only to find something else stupid (or not) fixed your build problems.

I've an install I'm quite happy with that has all of the working code I want on it working – and I've no interest in having to perform re-installs to get back to a working state again.

My solution, which I've used to great success with GAMESS-US, GROMACS, NWChem, and Amber (so far), is to break a virtual instance in VirtualBox first. For those who don't know (and briefly), VirtualBox lets you install a fully-working OS inside of your own OS that simply sits as a file in a Virtual VM folder in your user directory. My procedure has been to install a 60 GB VirtualBox instance of (currently) Ubuntu 14.04 (which I will refer to here as PROTOTYPE), fully update it to the current state of my RealBox (updates, upgrades, program installs, etc.), then copy PROTOTYPE somewhere else on the machine. The only limitation of this approach is that VirtualBox doesn't give you access to the GPU if you're testing CUDA-specific calculations. That said, it does let you install the CUDA Development Toolkit and compile code just fine, so you can at least work your way through a full build to make sure you don't run into problems.

When you're done trashing your VirtualBox after a particularly heinous build, just delete PROTOTYPE from Virtual VM and re-copy your copy back into Virtual VM – voila! You're ready for another build operation (or to make sure your "final" build actually works flawlessly before committing the build to your RealBox.

That's all I have to say on the matter. Consider it as your default procedure (at this point, I won't touch my RealBox with new installs until I know it's safe in VirtualBox).

1. The State Of My Machine Pre-GROMACS And All Other apt-get's Used Below

What follows below is pretty straightforward. Errors you might get that don't appear below might be related to the lack of certain installs on your machine that I installed on VirtualBox. That is, my standard PROTOTYPE comes standard with Intel's Fortran and C Compilers (for code optimization). Those installs required a few installs above the base Ubuntu install. These are (and are pretty standard anyway, so I say install them anyway):

sudo apt-get install build-essential gcc-multilib rpm openjdk-7-jre-headless 

I could have just installed a fresh version of 14.04 onto a machine to try this myself, but I'm not that motivated. Also, note this list does not include the all-important cmake. We'll get to that.

And for the rest of GROMACS (at least for older versions), there were lots of mesa/gnuplot/motif-specific dependencies in older versions of GROMACS to build all of the files included in the GROMACS package. Regardless of GPU builds or not, I tend to default to install all the packages below just to have them (which all, for 14.04, currently apt-get properly).

sudo apt-get install openmpi-bin openmpi-common gfortran csh grace menu x11proto-print-dev motif-clients freeglut3-dev libx11-dev libxmu-dev libxi-dev libgl1-mesa-glx libglu1-mesa libglu1-mesa-dev libgl1-mesa-dri libcurl-ocaml-dev libcurl4-gnutls-dev gnuplot

If you don't install the libblas3gf libblas-doc libblas-dev liblapack3gf liblapack-doc liblapack-dev series, you'll see the following note from your cmake steps in GROMACS.

— A library with BLAS API not found. Please specify library location.
— Using GROMACS built-in BLAS.
— LAPACK requires BLAS
— A library with LAPACK API not found. Please specify library location.
— Using GROMACS built-in LAPACK.

My own preference is to use the (assumedly newer) Ubuntu-specific libraries from apt-get.

sudo apt-get install libblas3gf libblas-doc libblas-dev liblapack3gf liblapack-doc liblapack-dev

GPU-Specific? One More apt-get

My first passes at proper GPU compilation involved several steps for the nVidia Developer Toolkit install. That's now taken care of with apt-get, so perform the final apt-get to complete the component/dependency installations.

sudo apt-get install nvidia-cuda-dev nvidia-cuda-toolkit

With luck, your first attempt at a GPU-based installation will look like the following:

[0%] Building NVCC (Device) object src/gromacs/gmxlib/cuda_tools/CMakeFiles/cuda_tools.dir//./cuda_tools_generated_copyrite_gpu.cu.o

[100%] Building CXX object src/programs/CMakeFiles/gmx.dir/legacymodules.cpp.o
Linking CXX executable http://www.somewhereville.com/bin/gmx
[100%] Built target gmx

2. Nothing Happens Without cmake

Install cmake! Reproducing the output below to make sure you're using the same versions for everything (in the event something breaks in the future).

sudo apt-get install cmake

Reading package lists… Done
Building dependency tree
Reading state information… Done
The following packages were automatically installed and are no longer required:
linux-headers-3.13.0-32 linux-headers-3.13.0-32-generic
linux-image-3.13.0-32-generic linux-image-extra-3.13.0-32-generic
Use 'apt-get autoremove' to remove them.
The following extra packages will be installed:
cmake-data
Suggested packages:
codeblocks eclipse
The following NEW packages will be installed:
cmake cmake-data
0 upgraded, 2 newly installed, 0 to remove and 0 not upgraded.
Need to get 3,294 kB of archives.
After this operation, 16.6 MB of additional disk space will be used.
Do you want to continue? [Y/n]
Get:1 http://us.archive.ubuntu.com/ubuntu/ trusty/main cmake-data all 2.8.12.2-0ubuntu3 [676 kB]
Get:2 http://us.archive.ubuntu.com/ubuntu/ trusty/main cmake amd64 2.8.12.2-0ubuntu3 [2,618 kB]
Fetched 3,294 kB in 30s (106 kB/s)
Selecting previously unselected package cmake-data.
(Reading database … 258157 files and directories currently installed.)
Preparing to unpack …/cmake-data_2.8.12.2-0ubuntu3_all.deb …
Unpacking cmake-data (2.8.12.2-0ubuntu3) …
Selecting previously unselected package cmake.
Preparing to unpack …/cmake_2.8.12.2-0ubuntu3_amd64.deb …
Unpacking cmake (2.8.12.2-0ubuntu3) …
Processing triggers for man-db (2.6.7.1-1) …
Setting up cmake-data (2.8.12.2-0ubuntu3) …
Setting up cmake (2.8.12.2-0ubuntu3) …

3. First Pass At GROMACS

The make install step will place GROMACS where you want it on your machine, so you're just as good building in $HOME/Downloads as you are anywhere else. I will be performing all operations from $HOME/Downloads unless otherwise stated.

According to the GROMACS Installation Manual, your quick-and-dirty install need only involve the following:

$ tar xvfz gromacs-src.tar.gz
$ ls
gromacs-src
$ mkdir build
$ cd build
$ cmake ../gromacs-src
$ make

This allows you build "out-of-source" as they put it. Frankly, I just dive right into the GROMACS folder and have at it.

CMake Error: The source directory "/home/user/Downloads/gromacs-5.0.1/build" does not appear to contain CMakeLists.txt.
Specify –help for usage, or press the help button on the CMake GUI.

And did you see the above error? If so, you read the GROMACS quick-and-dirty procedure backwards. I'm not running it this way, so doesn't matter to what follows.

My first attempt at building GROMACS produced the following output from PROTOTYPE (reproducing all the text below).

user@PROTOTYPE:~$ cd Downloads/
user@PROTOTYPE:~/Downloads$ gunzip gromacs-5.0.1.tar.gz 
user@PROTOTYPE:~/Downloads$ tar xvf gromacs-5.0.1.tar 

gromacs-5.0.1/README
gromacs-5.0.1/INSTALL

gromacs-5.0.1/tests/CppCheck.cmake
gromacs-5.0.1/tests/CMakeLists.txt

user@PROTOTYPE:~/Downloads$ cd gromacs-5.0.1/
user@PROTOTYPE:~/Downloads/gromacs-5.0.1$ cmake -DGMX_GPU=OFF

NOTE: If you just run cmake, you'll get the following…

cmake version 2.8.12.2
Usage

cmake [options] cmake [options]

… which is to say, cmake requires at least one option be specified. Above, I'm just using -DGMX_GPU=OFF to start the process.

The C compiler identification is GNU 4.8.2
— The CXX compiler identification is GNU 4.8.2
— Check for working C compiler: /usr/bin/cc
— Check for working C compiler: /usr/bin/cc — works
— Detecting C compiler ABI info
— Detecting C compiler ABI info – done
— Check for working CXX compiler: /usr/bin/c++
— Check for working CXX compiler: /usr/bin/c++ — works
— Detecting CXX compiler ABI info
— Detecting CXX compiler ABI info – done
— Checking for GCC x86 inline asm
— Checking for GCC x86 inline asm – supported
— Detecting best SIMD instructions for this CPU
— Detected best SIMD instructions for this CPU – SSE2
— Try OpenMP C flag = [-fopenmp]
— Performing Test OpenMP_FLAG_DETECTED
— Performing Test OpenMP_FLAG_DETECTED – Success
— Try OpenMP CXX flag = [-fopenmp]
— Performing Test OpenMP_FLAG_DETECTED
— Performing Test OpenMP_FLAG_DETECTED – Success
— Found OpenMP: -fopenmp
— Performing Test CFLAGS_WARN
— Performing Test CFLAGS_WARN – Success
— Performing Test CFLAGS_WARN_EXTRA
— Performing Test CFLAGS_WARN_EXTRA – Success
— Performing Test CFLAGS_WARN_REL
— Performing Test CFLAGS_WARN_REL – Success
— Performing Test CFLAGS_WARN_UNINIT
— Performing Test CFLAGS_WARN_UNINIT – Success
— Performing Test CFLAGS_EXCESS_PREC
— Performing Test CFLAGS_EXCESS_PREC – Success
— Performing Test CFLAGS_COPT
— Performing Test CFLAGS_COPT – Success
— Performing Test CFLAGS_NOINLINE
— Performing Test CFLAGS_NOINLINE – Success
— Performing Test CXXFLAGS_WARN
— Performing Test CXXFLAGS_WARN – Success
— Performing Test CXXFLAGS_WARN_EXTRA
— Performing Test CXXFLAGS_WARN_EXTRA – Success
— Performing Test CXXFLAGS_WARN_REL
— Performing Test CXXFLAGS_WARN_REL – Success
— Performing Test CXXFLAGS_EXCESS_PREC
— Performing Test CXXFLAGS_EXCESS_PREC – Success
— Performing Test CXXFLAGS_COPT
— Performing Test CXXFLAGS_COPT – Success
— Performing Test CXXFLAGS_NOINLINE
— Performing Test CXXFLAGS_NOINLINE – Success
— Looking for include file unistd.h
— Looking for include file unistd.h – found
— Looking for include file pwd.h
— Looking for include file pwd.h – found
— Looking for include file dirent.h
— Looking for include file dirent.h – found
— Looking for include file time.h
— Looking for include file time.h – found
— Looking for include file sys/time.h
— Looking for include file sys/time.h – found
— Looking for include file io.h
— Looking for include file io.h – not found
— Looking for include file sched.h
— Looking for include file sched.h – found
— Looking for include file regex.h
— Looking for include file regex.h – found
— Looking for C++ include regex
— Looking for C++ include regex – not found
— Looking for posix_memalign
— Looking for posix_memalign – found
— Looking for memalign
— Looking for memalign – found
— Looking for _aligned_malloc
— Looking for _aligned_malloc – not found
— Looking for gettimeofday
— Looking for gettimeofday – found
— Looking for fsync
— Looking for fsync – found
— Looking for _fileno
— Looking for _fileno – not found
— Looking for fileno
— Looking for fileno – found
— Looking for _commit
— Looking for _commit – not found
— Looking for sigaction
— Looking for sigaction – found
— Looking for sysconf
— Looking for sysconf – found
— Looking for rsqrt
— Looking for rsqrt – not found
— Looking for rsqrtf
— Looking for rsqrtf – not found
— Looking for sqrtf
— Looking for sqrtf – not found
— Looking for sqrt in m
— Looking for sqrt in m – found
— Looking for clock_gettime in rt
— Looking for clock_gettime in rt – found
— Checking for sched.h GNU affinity API
— Performing Test sched_affinity_compile
— Performing Test sched_affinity_compile – Success
— Check if the system is big endian
— Searching 16 bit integer
— Looking for sys/types.h
— Looking for sys/types.h – found
— Looking for stdint.h
— Looking for stdint.h – found
— Looking for stddef.h
— Looking for stddef.h – found
— Check size of unsigned short
— Check size of unsigned short – done
— Using unsigned short
— Check if the system is big endian – little endian
— Found LibXml2: /usr/lib/x86_64-linux-gnu/libxml2.so (found version "2.9.1")
— Looking for xmlTextWriterEndAttribute in /usr/lib/x86_64-linux-gnu/libxml2.so
— Looking for xmlTextWriterEndAttribute in /usr/lib/x86_64-linux-gnu/libxml2.so – found
— Looking for include file libxml/parser.h
— Looking for include file libxml/parser.h – found
— Looking for include file pthread.h
— Looking for include file pthread.h – found
— Looking for pthread_create
— Looking for pthread_create – not found
— Looking for pthread_create in pthreads
— Looking for pthread_create in pthreads – not found
— Looking for pthread_create in pthread
— Looking for pthread_create in pthread – found
— Found Threads: TRUE
— Looking for include file pthread.h
— Looking for include file pthread.h – found
— Atomic operations found
— Performing Test PTHREAD_SETAFFINITY
— Performing Test PTHREAD_SETAFFINITY – Success
— Could NOT find Boost
Boost >= 1.44 not found. Using minimal internal version. This may cause trouble if you plan on compiling/linking other software that uses Boost against Gromacs.
— Looking for zlibVersion in /usr/lib/x86_64-linux-gnu/libz.so
— Looking for zlibVersion in /usr/lib/x86_64-linux-gnu/libz.so – found
— Setting build user/date/host/cpu information
— Setting build user & time – OK
— Checking floating point format
— Checking floating point format – IEEE754 (LE byte, LE word)
— Checking for 64-bit off_t
— Checking for 64-bit off_t – present
— Checking for fseeko/ftello
— Checking for fseeko/ftello – present
— Checking for SIGUSR1
— Checking for SIGUSR1 – found
— Checking for pipe support
— Checking for isfinite
— Performing Test isfinite_compile_ok
— Performing Test isfinite_compile_ok – Success
— Checking for isfinite – yes
— Checking for _isfinite
— Performing Test _isfinite_compile_ok
— Performing Test _isfinite_compile_ok – Failed
— Checking for _isfinite – no
— Checking for _finite
— Performing Test _finite_compile_ok
— Performing Test _finite_compile_ok – Failed
— Checking for _finite – no
— Performing Test CXXFLAG_STD_CXX0X
— Performing Test CXXFLAG_STD_CXX0X – Success
— Performing Test GMX_CXX11_SUPPORTED
— Performing Test GMX_CXX11_SUPPORTED – Success
— Checking for system XDR support
— Checking for system XDR support – present
— Try C compiler SSE2 flag = [-msse2]
— Performing Test C_FLAG_msse2
— Performing Test C_FLAG_msse2 – Success
— Performing Test C_SIMD_COMPILES_FLAG_msse2
— Performing Test C_SIMD_COMPILES_FLAG_msse2 – Success
— Try C++ compiler SSE2 flag = [-msse2]
— Performing Test CXX_FLAG_msse2
— Performing Test CXX_FLAG_msse2 – Success
— Performing Test CXX_SIMD_COMPILES_FLAG_msse2
— Performing Test CXX_SIMD_COMPILES_FLAG_msse2 – Success
— Enabling SSE2 SIMD instructions
— Performing Test _callconv___vectorcall
— Performing Test _callconv___vectorcall – Failed
— Performing Test _callconv___regcall
— Performing Test _callconv___regcall – Failed
— Performing Test _callconv_
— Performing Test _callconv_ – Success
— checking for module 'fftw3f'
— package 'fftw3f' not found
— pkg-config could not detect fftw3f, trying generic detection
Could not find fftw3f library named libfftw3f, please specify its location in CMAKE_PREFIX_PATH or FFTWF_LIBRARY by hand (e.g. -DFFTWF_LIBRARY='/path/to/libfftw3f.so')
CMake Error at cmake/gmxManageFFTLibraries.cmake:76 (MESSAGE):
Cannot find FFTW 3 (with correct precision – libfftw3f for mixed-precision
GROMACS or libfftw3 for double-precision GROMACS). Either choose the right
precision, choose another FFT(W) library (-DGMX_FFT_LIBRARY), enable the
advanced option to let GROMACS build FFTW 3 for you
(-GMX_BUILD_OWN_FFTW=ON), or use the really slow GROMACS built-in fftpack
library (-DGMX_FFT_LIBRARY=fftpack).
Call Stack (most recent call first):
CMakeLists.txt:733 (include)

— Configuring incomplete, errors occurred!
See also "/home/user/Downloads/gromacs-5.0.1/CMakeFiles/CMakeOutput.log".
See also "/home/user/Downloads/gromacs-5.0.1/CMakeFiles/CMakeError.log".

Lots of little things to address here. We'll get to the Boost problem later. Meantime, you can see the critical error is in (1) the lack of FFTW3 and (2) the lack of my specifically asking for -DGMX_BUILD_OWN_FFTW=ON in the cmake process.

NOTE: If you try to fix the FFTW3 problem as described above, you'll get the following error:

-GMX_BUILD_OWN_FFTW=ON

CMake Error: Could not create named generator MX_BUILD_OWN_FFTW=ON

Make sure to put the "D" in:

-DGMX_BUILD_OWN_FFTW=ON

4. If You Don't Use DGMX_BUILD_OWN_FFTW=ON To Build FFTW3…

This is a skip-able section if you're letting cmake do the dirty work (and letting cmake do it is preferred, at least for getting GROMACS built). In trying sudo apt-get install fftw*, you see (currently) the following: fftw2 fftw-dev fftw-docs

No good. So, the procedure is to build FFTW3 from source (which is just as easy as installing from .deb or .rpm files if you installed everything I mentioned above). That said, your attempts to build FFTW3 and build GROMACS may have run into several errors because of how you built FFTW3. Beginning with your extracting and prep for make:

user@PROTOTYPE:~/Downloads$ tar xvf fftw-3.3.4.tar 
user@PROTOTYPE:~/Downloads$ cd fftw-3.3.4/

Any of the combinations below produce the same error:

user@PROTOTYPE:~/Downloads/fftw-3.3.4$ ./configure 
user@PROTOTYPE:~/Downloads/fftw-3.3.4$ ./configure -enable-shared=yes
user@PROTOTYPE:~/Downloads/fftw-3.3.4$ ./configure --enable-threads --enable-float

checking for a BSD-compatible install… /usr/bin/install -c
checking whether build environment is sane… yes

config.status: executing depfiles commands
config.status: executing libtool commands

user@PROTOTYPE:~/Downloads/gromacs-5.0.1$ cmake -DGMX_GPU=OFF
user@PROTOTYPE:~/Downloads/gromacs-5.0.1$ cmake -DGMX_GPU=OFF -DFFTWF_LIBRARY='/usr/local/lib/libfftw3.a'

— The C compiler identification is GNU 4.8.2
— The CXX compiler identification is GNU 4.8.2
— Check for working C compiler: /usr/bin/cc

— Performing Test PTHREAD_SETAFFINITY
— Performing Test PTHREAD_SETAFFINITY – Success
— Could NOT find Boost
Boost >= 1.44 not found. Using minimal internal version. This may cause trouble if you plan on compiling/linking other software that uses Boost against Gromacs.
— Looking for zlibVersion in /usr/lib/x86_64-linux-gnu/libz.so
— Looking for zlibVersion in /usr/lib/x86_64-linux-gnu/libz.so – found

— checking for module 'fftw3f'
— package 'fftw3f' not found
— pkg-config could not detect fftw3f, trying generic detection
Could not find fftw3f library named libfftw3f, please specify its location in CMAKE_PREFIX_PATH or FFTWF_LIBRARY by hand (e.g. -DFFTWF_LIBRARY='/path/to/libfftw3f.so')
CMake Error at cmake/gmxManageFFTLibraries.cmake:76 (MESSAGE):
Cannot find FFTW 3 (with correct precision – libfftw3f for mixed-precision
GROMACS or libfftw3 for double-precision GROMACS). Either choose the right
precision, choose another FFT(W) library (-DGMX_FFT_LIBRARY), enable the
advanced option to let GROMACS build FFTW 3 for you
(-GMX_BUILD_OWN_FFTW=ON), or use the really slow GROMACS built-in fftpack
library (-DGMX_FFT_LIBRARY=fftpack).
Call Stack (most recent call first):
CMakeLists.txt:733 (include)

— Configuring incomplete, errors occurred!
See also "/home/user/Downloads/gromacs-5.0.1/CMakeFiles/CMakeOutput.log".
See also "/home/user/Downloads/gromacs-5.0.1/CMakeFiles/CMakeError.log".

Including –enable-shared takes care of this error and gets you to a successful GROMACS build.

user@PROTOTYPE:~/Downloads/fftw-3.3.4$ ./configure --enable-threads --enable-float --enable-shared

— The C compiler identification is GNU 4.8.2
— The CXX compiler identification is GNU 4.8.2
— Check for working C compiler: /usr/bin/cc

— Performing Test PTHREAD_SETAFFINITY
— Performing Test PTHREAD_SETAFFINITY – Success
— Could NOT find Boost
Boost >= 1.44 not found. Using minimal internal version. This may cause trouble if you plan on compiling/linking other software that uses Boost against Gromacs.
— Looking for zlibVersion in /usr/lib/x86_64-linux-gnu/libz.so
— Looking for zlibVersion in /usr/lib/x86_64-linux-gnu/libz.so – found

— checking for module 'fftw3f'
— found fftw3f, version 3.3.4
— Looking for fftwf_plan_r2r_1d in /usr/local/lib/libfftw3f.so
— Looking for fftwf_plan_r2r_1d in /usr/local/lib/libfftw3f.so – found
— Looking for fftwf_have_simd_avx in /usr/local/lib/libfftw3f.so
— Looking for fftwf_have_simd_avx in /usr/local/lib/libfftw3f.so – not found
— Looking for fftwf_have_simd_sse2 in /usr/local/lib/libfftw3f.so
— Looking for fftwf_have_simd_sse2 in /usr/local/lib/libfftw3f.so – not found
— Looking for fftwf_have_simd_avx in /usr/local/lib/libfftw3f.so
— Looking for fftwf_have_simd_avx in /usr/local/lib/libfftw3f.so – not found
— Looking for fftwf_have_simd_altivec in /usr/local/lib/libfftw3f.so
— Looking for fftwf_have_simd_altivec in /usr/local/lib/libfftw3f.so – not found
— Looking for fftwf_have_simd_neon in /usr/local/lib/libfftw3f.so
— Looking for fftwf_have_simd_neon in /usr/local/lib/libfftw3f.so – not found
— Looking for fftwf_have_sse2 in /usr/local/lib/libfftw3f.so
— Looking for fftwf_have_sse2 in /usr/local/lib/libfftw3f.so – not found
— Looking for fftwf_have_sse in /usr/local/lib/libfftw3f.so
— Looking for fftwf_have_sse in /usr/local/lib/libfftw3f.so – not found
— Looking for fftwf_have_altivec in /usr/local/lib/libfftw3f.so
— Looking for fftwf_have_altivec in /usr/local/lib/libfftw3f.so – not found
CMake Warning at cmake/gmxManageFFTLibraries.cmake:89 (message):
The fftw library found is compiled without SIMD support, which makes it
slow. Consider recompiling it or contact your admin
Call Stack (most recent call first):
CMakeLists.txt:733 (include)

— Using external FFT library – FFTW3
— Looking for sgemm_

— Configuring done
— Generating done
— Build files have been written to: /home/user/Downloads/gromacs-5.0.1

And out of a first-pass GROMACS build…

user@PROTOTYPE:~/Downloads/gromacs-5.0.1$ cmake -DGMX_GPU=OFF

Scanning dependencies of target libgromacs
[0%] Building C object src/gromacs/CMakeFiles/libgromacs.dir/__/external/tng_io/src/compression/bwlzh.c.o
[0%] Building C object src/gromacs/CMakeFiles/libgromacs.dir/__/external/tng_io/src/compression/bwt.c.o

[100%] Building CXX object src/programs/CMakeFiles/gmx.dir/legacymodules.cpp.o
Linking CXX executable http://www.somewhereville.com/bin/gmx
[100%] Built target gmx

5. But You Let cmake Build FFTW3. So, Continuing The Build Process

With all of the dependencies above installed, the one note I wanted to address was that for Boost:


— Performing Test PTHREAD_SETAFFINITY – Success
— Could NOT find Boost
Boost >= 1.44 not found. Using minimal internal version. This may cause trouble if you plan on compiling/linking other software that uses Boost against Gromacs.
— Looking for zlibVersion in /usr/lib/x86_64-linux-gnu/libz.so

It certainly isn't a major issue, but I wanted to try to get an warning-free build. Installing Boost 1.56 produced the following negative result:

user@PROTOTYPE:~/Downloads/boost_1_56_0$ ./bootstrap.sh 

Building Boost.Build engine with toolset gcc… tools/build/src/engine/bin.linuxx86_64/b2
Detecting Python version… 2.7
Detecting Python root… /usr
Unicode/ICU support for Boost.Regex?… not found.
Generating Boost.Build configuration in project-config.jam…

Bootstrapping is done. To build, run:

./b2

To adjust configuration, edit 'project-config.jam'.
Further information:

– Command line help:
./b2 –help

– Getting started guide:
http://www.boost.org/more/getting_started/unix-variants.html

– Boost.Build documentation:
http://www.boost.org/boost-build2/doc/html/index.html

user@PROTOTYPE:~/Downloads/boost_1_56_0$ sudo ./b2 install

Performing configuration checks

– 32-bit : no (cached)
– 64-bit : yes (cached)
– arm : no (cached)

…failed updating 58 targets…
…skipped 12 targets…
…updated 11322 targets…

user@PROTOTYPE:~/Downloads/gromacs-5.0.1$ cmake -DGMX_GPU=ON -DGMX_DOUBLE=OFF
user@PROTOTYPE:~/Downloads/gromacs-5.0.1$ make

[0%] Building NVCC (Device) object src/gromacs/gmxlib/cuda_tools/CMakeFiles/cuda_tools.dir//./cuda_tools_generated_copyrite_gpu.cu.o
[0%] Building NVCC (Device) object src/gromacs/gmxlib/cuda_tools/CMakeFiles/cuda_tools.dir//./cuda_tools_generated_pmalloc_cuda.cu.o

[7%] Building CXX object src/gromacs/CMakeFiles/libgromacs.dir/commandline/cmdlinehelpwriter.cpp.o
In file included from /home/user/Downloads/gromacs-5.0.1/src/gromacs/options/basicoptions.h:52:0,
from /home/user/Downloads/gromacs-5.0.1/src/gromacs/commandline/cmdlinehelpwriter.cpp:55:
/home/user/Downloads/gromacs-5.0.1/src/gromacs/options/../utility/gmxassert.h:47:57: fatal error: boost/exception/detail/attribute_noreturn.hpp: No such file or directory
#include
^
compilation terminated.
make[2]: *** [src/gromacs/CMakeFiles/libgromacs.dir/commandline/cmdlinehelpwriter.cpp.o] Error 1
make[1]: *** [src/gromacs/CMakeFiles/libgromacs.dir/all] Error 2
make: *** [all] Error 2

Sadly, the solution is to then include -DGMX_EXTERNAL_BOOST=off and stick with the internal boost, which then "makes" just fine. One page references the use of -DGMX_INTERNAL_BOOST=on, but that produced the following:

CMake Warning:
Manually-specified variables were not used by the project:

GMX_INTERNAL_BOOST

— Build files have been written to: /home/user/Downloads/gromacs-5.0.1

There's more on this issue at: gerrit.gromacs.org/#/c/1232/ and t24960.science-biology-gromacs-development.biotalk.us/compiling-boost-problem-and-error-with-icc-t24960.html, but I've opted not to worry about it.

So, with Boost installed, I simply ignore it (and have not installed Boost on my RealBox).

user@PROTOTYPE:~/Downloads/gromacs-5.0.1$ cmake -DGMX_GPU=ON -DGMX_EXTERNAL_BOOST=off

6. Finishing Step If All Above Goes Well: CUDA-Based GROMACS Build

If everything else above has gone smoothly (and if you ignored the Boost install. If you didn't, remember to add -DGMX_EXTERNAL_BOOST=off to the cmake below), you should be able to cleanly run a cmake for a GPU version of GROMACS (below, with the final result to be placed into /opt/gromacs_gpu. You then specify the $PATH after and run with it).

user@PROTOTYPE:~/Downloads/gromacs-5.0.1$ cmake -DGMX_GPU=ON -DCMAKE_INSTALL_PREFIX=/opt/gromacs_gpu -DGMX_BUILD_OWN_FFTW=ON

— The C compiler identification is GNU 4.8.2
— The CXX compiler identification is GNU 4.8.2

— Generating done
— Build files have been written to: /home/damianallis/Downloads/gromacs-5.0.1

user@PROTOTYPE:~/Downloads/gromacs-5.0.1$ make

The make starts with the FFTW3 download and build…

Scanning dependencies of target fftwBuild
[ 0%] Performing pre-download step for 'fftwBuild'
— downloading…
src='http://www.fftw.org/fftw-3.3.3.tar.gz'
dest='/home/damianallis/Downloads/gromacs-5.0.1/src/contrib/fftw/fftw.tar.gz'
— [download 0% complete]

[100%] Building CXX object src/programs/CMakeFiles/gmx.dir/legacymodules.cpp.o
Linking CXX executable http://www.somewhereville.com/bin/gmx
[100%] Built target gmx

Finally, your (sudo) make install places everything into /opt/gromacs_gpu.

user@PROTOTYPE:~/Downloads/gromacs-5.0.1$ sudo make install

— The GROMACS-managed build of FFTW 3 will configure with the following optimizations: –enable-sse2
— Configuring done
— Generating done
— Build files have been written to: /home/damianallis/Downloads/gromacs-5.0.1
[1%] Built target fftwBuild

[100%] Building CXX object src/programs/CMakeFiles/gmx.dir/legacymodules.cpp.o
Linking CXX executable http://www.somewhereville.com/bin/gmx
[100%] Built target gmx