AlexanderDilthey / kMerificator

GNU General Public License v3.0
1 stars 1 forks source link

Installing on Mac OS and Ubuntu, future README revision #2

Open evanbiederstedt opened 4 years ago

evanbiederstedt commented 4 years ago

This is more of a note to my self for the future, but I suppose one could revise the README in the future.

In order to compile on a Mac (circa 2020, v10.15.2):

Recall gcc on Mac isn't gcc. And the llvm libraries installed via brew do not contain standard C++ libraries. https://stackoverflow.com/questions/14128298/using-homebrew-gcc-and-llvm-with-c-11

So the Makefile I wrote up uses the following:

## boost libraries installed via brew
INC_BOOST = /usr/local/Cellar/boost/1.72.0/include
LIB_BOOST = /usr/local/Cellar/boost/1.72.0/lib
INCS = -I$(INC_BOOST) 
LIBS = -L$(LIB_BOOST) -lboost_system -lboost_filesystem
### explicitly set these
DIR_OBJ = /Users/evanbiederstedt/kMerificator/obj
DIR_BIN = /Users/evanbiederstedt/kMerificator/bin
## I suspect I've named these incorrectly...
CPP = clang++ -std=c++11 -stdlib=libc++
CPPFLAGS = -I/usr/local/opt/llvm/include -fopenmp
LDFLAGS = -L/usr/local/opt/llvm/lib
COPTS  = -ggdb -O2 -fopenmp -std=gnu++0x -fstack-protector-all
## CFLAGS = 
COMPILE = $(CPP) $(COPTS) $(INCS) $(CPPFLAGS) $(LDFLAGS)

Here is the entire Makefile, which worked:

# LIBRARY SETTINGS - SET AS NECESSARY

INC_BOOST = /usr/local/Cellar/boost/1.72.0/include
LIB_BOOST = /usr/local/Cellar/boost/1.72.0/lib
INCS = -I$(INC_BOOST) 
LIBS = -L$(LIB_BOOST) -lboost_system -lboost_filesystem

MKDIR_P = mkdir -p

.PHONY: directories

# END LIBRARY SETTINGS

#
# object and binary dirs
#

DIR_OBJ = /Users/evanbiederstedt/kMerificator/obj
DIR_BIN = /Users/evanbiederstedt/kMerificator/bin

CPP = clang++ -std=c++11 -stdlib=libc++
CPPFLAGS = -I/usr/local/opt/llvm/include -fopenmp
LDFLAGS = -L/usr/local/opt/llvm/lib
CXX    = g++
COPTS  = -ggdb -O2 -fopenmp -std=gnu++0x -fstack-protector-all
## CFLAGS = 
COMPILE = $(CPP) $(COPTS) $(INCS) $(CPPFLAGS) $(LDFLAGS)

VPATH = Data:Graph:NextGen:hash:hash/deBruijn:hash/sequence:GraphAligner:GraphAlignerUnique:readFilter

OBJS = \
        $(DIR_OBJ)/Utilities.o \
        $(DIR_OBJ)/DeBruijnGraph.o \
        $(DIR_OBJ)/DeBruijnElement.o \
        $(DIR_OBJ)/basic.o \
        $(DIR_OBJ)/binarykMer.o \
        $(DIR_OBJ)/Hsh.o \
        $(DIR_OBJ)/Validator.o \
#
# list executable file names
#
EXECS = kMerificator

OUT_DIR = ../obj ../bin

directories: ${OUT_DIR}

#
# compile and link
#
default:
    @echo
    @echo " to build:"
    @echo "    make all"
    @echo
    @echo " to clean:"
    @echo "    make clean"
    @echo "    make realclean"
    @echo

all: directories $(EXECS)

$(EXECS): $(OBJS)
    $(foreach EX, $(EXECS), $(COMPILE) $(EX).cpp -c -o $(DIR_OBJ)/$(EX).o;)
    $(foreach EX, $(EXECS), $(COMPILE) $(OBJS) $(DIR_OBJ)/$(EX).o -o $(DIR_BIN)/$(EX) $(LIBS);)

$(DIR_OBJ)/%.o: %.cpp %.h
    $(COMPILE) $< -c -o $@

#
# odds and ends
#
clean:
    /bin/rm $(DIR_OBJ)/*

realclean: clean
    /bin/rm $(DIR_BIN)/*

${OUT_DIR}:
    ${MKDIR_P} ${OUT_DIR}
evanbiederstedt commented 4 years ago

On ubuntu, this installed easily!

I'm using Ubuntu 18.04

Distributor ID: Ubuntu
Description:    Ubuntu 18.04.4 LTS
Release:    18.04
Codename:   bionic

The only "special" dependency (I think) was:

sudo apt-get install libboost-all-dev

Note: For ubuntu, the boost headers are in /usr/include/boost and the libraries are in /usr/lib/x86_64-linux-gnu/, i.e. set the paths to the following:

INC_BOOST = /usr/include/boost/
LIB_BOOST = /usr/lib/x86_64-linux-gnu/

$ g++ --version
g++ (Ubuntu 7.4.0-1ubuntu1~18.04.1) 7.4.0
Copyright (C) 2017 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

I did need to set the following to absolute paths though:

DIR_OBJ = /home/software/kMerificator/obj
DIR_BIN = /home/software/kMerificator/bin

The default ../obj and ../bin wouldn't work.