Tuesday, July 9, 2013

Step-by-step to install Shark Lib on Ubuntu

Step 1: Install g++
Check whether g++ compiler has been installed on the target Linux machine by entering the following in the command prompt:
$g++

If the target Linux machine indicates no g++ compiler is installed on the machine, proceed to install the compiler by entering the following in the command prompt:
$sudo apt-get install g++

Step 2: Install CMake
Check whether cmake has been installed on the target linux machine, by entering the following in the command prompt:
$cmake -help

If the target linux machine indicates no cmake is installed on the machine, proceed to install cmake by entering the following in the command prompt:
$sudo apt-get install cmake

Step 3: Install Shark
To install Shark library, download the software package shark-2.3.4.zip from
http://sourceforge.net/projects/shark-project/files/

Unzip it (to unzip, if you are using ubuntu, right-click the zip file and click "Extract Here" from the context menu), next cd to the unzipped "Shark" folder, and run the following commands:
$cmake
$make
$sudo make install
This will install Shark (where using ubuntu, the installed directory can be found at usr/local)

Step 4: Makefile
Below is an example of the makefile which include the Shark lib for building the solver (the highlighted part is the Shark lib related)

SHARKHOME=/usr/local

LDLIBS=-lshark
LDFLAGS=-L${SHARKHOME}/lib -Wl,-rpath,${SHARKHOME}/lib
CXXFLAGS=-O3 -I${SHARKHOME}/include

PROBLEMDIR=..
OBJDIR=Objs
MDOLIB=../../../Solvers
SOLVER=../../../Solvers/NSGA2

CC=g++
SOURCES       = $(SOLVER)/Nsga2.cpp \
main.cpp \
$(PROBLEMDIR)/Problem_TNK.cpp \
$(MDOLIB)/Problem.cpp 
OBJECTS       = $(OBJDIR)/Nsga2.o \
$(OBJDIR)/main.o \
$(OBJDIR)/Problem_TNK.o \
$(OBJDIR)/Problem.o 

EXECUTABLE=NSGA2

all: $(SOURCES) $(EXECUTABLE)

$(EXECUTABLE): $(OBJECTS) 
$(CXX) $(OBJECTS) -o $@ $(LDFLAGS) $(LDLIBS) 

####### Compile

$(OBJDIR)/Nsga2.o: $(SOLVER)/Nsga2.cpp $(SOLVER)/Nsga2.h
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o $(OBJDIR)/Nsga2.o $(SOLVER)/Nsga2.cpp

$(OBJDIR)/Problem.o: $(MDOLIB)/Problem.cpp $(MDOLIB)/Problem.h
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o $(OBJDIR)/Problem.o $(MDOLIB)/Problem.cpp

$(OBJDIR)/Problem_TNK.o: $(PROBLEMDIR)/Problem_TNK.cpp $(PROBLEMDIR)/Problem_TNK.h \
$(MDOLIB)/Problem.h
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o $(OBJDIR)/Problem_TNK.o $(PROBLEMDIR)/Problem_TNK.cpp

$(OBJDIR)/main.o: main.cpp $(SOLVER)/Nsga2.h  
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o $(OBJDIR)/main.o main.cpp


####### Clean

clean: 
rm -f *.o *~ *.out *.txt
rm -f ${EXECUTABLE} ${OBJECTS}




No comments:

Post a Comment