Showing posts with label Linux. Show all posts
Showing posts with label Linux. Show all posts

Tuesday, November 3, 2015

Create and Run Apache Spark Scala project using Eclipse and SBT

This post shows a simple way to create and run a apache spark scala project using eclipse and SBT. Following this post at link (http://czcodezone.blogspot.sg/2015/11/create-scala-project-using-scala-ide.html) to create a SBT-compatiable scala project in Scala IDE, open the build.sbt in the project and add the following line towards the end of the file.

libraryDependencies += "org.apache.spark" %% "spark-core" % "1.5.1"

Further more, since Spark needs to run a spark cluster in a jar, a sbt plugin must be added for the packaging. Create a file named "assembly.sbt" in the "project" folder under the root directory and put the following content:

addSbtPlugin("com.eed3si9n" % "sbt-assembly" % "0.11.2")


Now in the command line, navigate to the project root directory and run "sbt compile", "sbt package" command after you put in your spark scala code, then "sbt run" or "spark-submit" depending on whether you want to run it locally or submit to spark cluster

Create a Scala project using Scala-IDE and SBT on CentOS

This post shows how to create and build a Scala project using  Scala IDE and SBT (Simple Build Tool)

Step 1: Create  a Scala project using Scala IDE


Download, unzip and launch the Scala IDE (link:  http://scala-ide.org/), use the IDE to create a Scala project (said, with a name "ScalaHelloWorld")

Step 2: Install SBT

Download and install SBT using the following command:

> curl https://bintray.com/sbt/rpm/rpm | sudo tee /etc/yum.repos.d/bintray-sbt-rpm.repo
> sudo yum install sbt

Step 3: Configure Scala project for SBT


After installing the SBT, navigate to your "ScalaHelloWorld" root directory and create a build.sbt file in the directory with the following content:

name := "File Searcher"

version := "1.0"

scalaVersion := "2.10.4"

libraryDependencies += "org.scalatest" % "scalatest_2.10" % "2.0" % "test"

Next in the root directory create a folder named "project" and create plugins.sbt file in the created "project" folder, with the following content:

addSbtPlugin("com.typesafe.sbteclipse" % "sbteclipse-plugin" % "4.0.0")


Now go back to the root directory and in the command line enter the following command:

> sbt eclipse

This will setup the eclipse scala project for sbt to work with. To begin writing Scala implementation, a simple recommendation with to create the folder structures like the following in the "src" folder under the root directory:

src/main/scala
src/main/resources
src/test/scala
src/test/resources

Now in the Scala IDE, right-click the folder "src/main/scala" and "src/test/scala" and select "Build Path -> Use as Source Folder", and just create your .scala file in these folders.

Step 4: Run SBT

After you code your scala implementation, navigate to the project root directory and type the following command to run the unit test codes:

> sbt test

And the following command to launch the app in main:

> sbt run

Tuesday, October 27, 2015

Install Nide on CentOS

One headache i have is with the use of vi on command line of VM to edit complex script. I recently found the alternative of using Nide. Nide is a web-based editor which allows user to remotely view and edit files in a VM using a web interface. this post shows a step-by-step installation guide on how to make it run on centos or scientific linux

Install nodejs in VM

To install nodejs on centos, run the following commands:

> cd /opt
> wget http://nodejs.org/dist/v0.10.30/node-v0.10.30.tar.gz
> tar xvzf node-v0.10.30.tar.gz
> cd node-v0.10.30
> ./configure
> sudo yum install gcc gcc-c++
> make
> make-install

Now run the following command to see if it is installed:

> node --version

Install npm in VM

To install npm, run the following commands 
> curl -SL https://rpm.nodesource.com/setup | bash -

Run the following command to see if it is installed:

> npm --version

Install nide

Run the following command to install nide

> npm install -g nide

Run nide in VM


After nide is installed, before proceed to launch it, the first thing is to make sure that the port that it listen can be accessible from VM, if not run some command like the following to open the port (in this case, it is port 80):

> iptables -I INPUT 5 -i eth0 -p tcp --dport 80 -m state --state NEW,ESTABLISHED -j ACCEPT

One more thing to make sure before the launching is to make sure that the node_modules in which nide is installed have the proper permission, by running the following command:

> sudo chown -R $USER /usr/local/lib/node_modules

Now, one can launch the nide at port 80 using the following command:

> nide init -p 80

And you can go to your local machine, and enter the address "http://[VM-IP]" (where VM-IP is the ip address of the VM, since you are running nide at port 80 here, no need to add the port number). Now you are free to view and edit files in your VM.

Thursday, October 15, 2015

Scentific Linux / CentOS: investigate system error

Some simple commands to check system errors in centos or scentific linux:

To check the list of errors:
> grep -i error /var/log/messages

To check login:
> tail --lines=200 /var/log/secure

To check when the system is shutdown:
> grep -i shutdown /var/log/messages

Under centos the /var/log/messages is equivalent to /var/log/syslog in Ubuntu

Eclipse: Black tooltip background when running eclipse on centos and scentific linux

I have been use eclipse for java development but recently i migrated the eclipse over from centos and scentific linux, now the eclipse running on centos and scentific linux have a black tooltip when user hover over the codes. The problem seems to be related to GTK which eclipse use.

Solution:
Create a "start.sh" in the eclipse root folder, make it executable. then put the following two lines in the files:

export SWT_GTK3=0
./eclipse

Now launch the "start.sh" instead of "eclipse" executable.

While the above solution seems to temporarily solve the black tooltip problem for me, eclipse will occasionally crash due to issues button size cannot be determined. Today, my colleague comes up with a better solution which is to replace the default desktop environment in centos with the xfce http://www.xfce.org/. This completely remove the issue with black tooltip background in eclipse.

Wednesday, June 17, 2015

docker on centos 7: are you trying to connect to a tls-enabled daemon without tls

After install docker on centos 7 and try to run a simple docker command such as "sudo docker images", it failes with this error message:

"Get http:///var/run/docker.sock/v1.18/images/json: dial unix /var/run/docker.sock: permission denied. Are you trying to connect to a TLS-enabled daemon without TLS?"

After some trial and error, it appears that centos actually does not launch docker service (not sure something to do with firewall in centos 7), anyway, running the "sudo service docker start" fix the problem.

Install and start docker on centos 7

Nice post on how to install and start docker on centos 7:

Link: http://www.liquidweb.com/kb/how-to-install-docker-on-centos-7/

Check Linux OS version of a cloud computing instance

To list the linux kernel version, etc, run:

> uname -a

If the os is redhat family, run:

> cat /etc/redhat-release

Thursday, December 11, 2014

Ubuntu: copy file from local computer to another computer.

To copy a file (e.g. /var/app.jar) from the local computer to the "/tmp" folder of a remote computer (said root@192.168.2.2), run the following command:

> scp /var/app.jar root@192.168.2.2:/tmp

Monday, November 24, 2014

Setup and run MySQL on Ubuntu 14.04 LTS

Suppose you want to install and run MySQL on Ubuntu, run the following commands to install the MySQL in the terminal:

> sudo apt-get install mysql-server
> sudo apt-get install mysql-client

During the installation of the mysql-server, the user will prompted to enter the password for the root user account. After the installation is completed, the user can run the following command to find out whether mysql-server is running on the computer:

> sudo netstat -tap | grep mysql

To start, stop or restart mysql, run one of the following commands:

> sudo /etc/init.d/mysql start
> sudo /etc/init.d/mysql stop
> sudo /etc/init.d/mysql restart

To log into mysql, run the following command

> sudo mysql -u [username] -p

Enter the password in the prompt and press ENTER. For example, to log into the root user account:

> mysql -u root -p

After logging into mysql, first select the database by running the following sql command (which select the database "mysql" which is the default):

> use mysql;

To list the tables in the "mysql" database, run the following sql command:

> show tables;

Now suppose we want to take a look at what is inside the "user" datatable. Run the following sql command:

> select * from user;

To create and select a new database, e.g., "mylog", run the following sql command:

> create database mylog;
> use mylog;

To create a datatable, e.g., "mylogtable", in the database "mylog", run the following sql commands:

> use mylog;
> create table mylogtable(
id INT NOT NULL AUTO_INCREMENT,
country VARCHAR(255) NULL);

To exit mysql, run the following sql command:

> quit;

Saturday, November 22, 2014

Setup Kafka in a cluster

To setup Kafka in a cluster, first we must have the zookeeper cluster setup and running (follow this link: http://czcodezone.blogspot.sg/2014/11/setup-zookeeper-in-cluster.html), suppose that the zookeeper cluster consists of the zookeeper servers running at the following hostname:ports:

192.168.2.2:2181
192.168.2.4:2181

As I have only two computers, therefore i will use the same computers (but at different ports) to host the kafka cluster. For this case, the Kafka servers/brokers will be running at the following hostname:ports

192.168.2.2:9092
192.168.2.4:9092

To do this, follow this link (http://czcodezone.blogspot.sg/2014/11/setup-kafka-in-single-machine-running.html) to setup the kafka server. Now navigate to the kafka root folder oif each computer and modify the server.properties in "config" sub folder:

> cd $KAFKA_HOME
> gedit config/server.properties

In the server.properties file, search the line "zookeeper.connect" and change it to:

zookeeper.connect=192.168.2.2:2181,192.168.2.4:2181

Then search the line "broker.id" (unique id for each broker node) and change it to "broke.id=1" on computer 192.168.2.2 and to "broker.id=2" on computer 192.168.2.4

Next search the line "host.name" and change it to "host.name=192.168.2.2" on computer 192.168.2.2 and to "host.name=192.168.2.4" on computer 192.168.2.4

Make sure that the line "port=9092" is there and uncommented in the server.properties

Save and close the server.properties. Now start the kafka server on each computer:

> cd $KAFKA_HOME
> bin/kafka-server-start.sh config/server.properties

At this point, the kafka cluster is set up and running. We can test the cluster by creating a topic named "v-topic":

> bin/kakfa-topics.sh --create --zookeeper 192.168.2.4:2181 --partitions 2 --replication-factor 1 --topic v-topic

Now run the following commands to list the topics in the kafka brokers:

> bin/kafka-topics.sh --zookeeper 192.168.2.4:2181 --list

Now run the following commands to get a description how the topic "v-topic" is partitioned in each broker:

> bin/kafka-topics.sh --describe --zookeeper 192.168.2.4:2181 --topic v-topic

To test the producer and consumer interaction, let's start a consoler producer on the computer 192.168.2.4 by running the following command on that computer's terminal:

> cd $KAFKA_HOME
> bin/kafka-console-producer.sh --broker-list 192.168.2.2:9092,192.168.2.4:9092 --topic v-topic

Now open a terminal of the other computer 192.168.2.4 and start a console consumer:

> cd $KAFKA_HOME
> bin/kafka-console-consumer.sh --zookeeper 192.168.2.4:2181 --topic v-topic --from-beginning

Begin to type something in the console producer on 192.168.2.2 terminal and press ENTER, you will see the output displayed in the console consumer on 192.168.2.4 terminal.

Note:

It is also ok to set up multiple Kafka brokers on the same computer. For example, if we want to have two Kafka brokers running at two different ports on computer 192.168.2.2, say:

192.168.2.2:9092
192.168.2.2:9093

Now all that we need to do is to duplicate the server.properties after it is updated, and rename it server1.properties in the same "config" folder (note that name is not important, can be anything that make sense). Now in the server1.properties, modify to have the following settings:

broker.id=3
log.dirs=/var/kafka1-logs
port=9093

Save and close server1.properties (remember to create the folder /var/kafka1-logs with write permission), open two terminal in 192.168.2.2 and run the following command in the first terminal to start a kafka broker at port 9092:

> $KAFKA_HOME/bin/kafka-server-start.sh $KAFKA_HOME/config/server.properties

On the second terminal, run the following command to start a second kafka broker at port 9093:

> $KAFKA_HOME/bin/kafka-server-start.sh $KAFKA_HOME/config/server1.properties

Now you will have two kafka brokers running on 192.168.2.2 on two different ports. To include the second broker for the console producer, change its start command to:

> $KAKFA_HOME/bin/kafka-console-producer.sh --broker-list 192.168.2.2:9092,192.168.2.2:9093,192.168.2.4:9092 --topic v-topic


Setup Kafka in a single machine running Ubuntu 14.04 LTS

Kafka is a messaging system that can acts as a buffer and feeder for messages processed by Storm spouts. It can also be used as a output buffer for Storm bolts. This post shows how to setup and test Kafka on a single machine running Ubuntu.

Firstly download the kafka 0.8.1.1 from the link below:

https://www.apache.org/dyn/closer.cgi?path=/kafka/0.8.1.1/kafka_2.8.0-0.8.1.1.tgz

Next "tar -xvzf" the kafka_2.8.0-0.8.1.1.tgz file and move it to a destination folder (say, /Documents/Works/Kafka folder under the user root directory):

> tar -xvzf kafka_2.8.0-0.8.1.1.tgz
> mkdir $HOME/Documents/Works/Kafka
> mv kafka_2.8.0-0.8.1.1 $HOME/Documents/Works/Kafka

Now go back to the user root folder and open the .bashrc file for editing:

> cd $HOME
> gedit .bashrc

In the .bashrc file, add the following line to the end:

export KAFKA_HOME=$HOME/Documents/Works/Kakfa/kafka_2.8.0-0.8.1.1

Save and close the .bashrc and run "source .bashrc" to update the environment variables. Now navigate to the kafka home folder and edit the server.properties in its sub-directory "config":

> cd $KAFKA_HOME/config
> gedit server.properties

In the server.properties file, search the line "zookeeper.connect" and change it to the following:

zookeeper.connect=192.168.2.2:2181,192.168.2.4:2181

search the line "log.dirs" and change it to the following:

log.dirs=/var/kafka-logs

Save and close the server.properties file (192.168.2.2 and 192.168.2.4 are the zookeeper nodes). Next we go and create the folder /var/kafka-logs (which will store the topics and partitions data for kafka) with write permissions:

> sudo mkdir /var/kafka-logs
> sudo chmod -R 777 /var/kafka-logs

Now set up and run the zookeeper cluster by following instructions in the link http://czcodezone.blogspot.sg/2014/11/setup-zookeeper-in-cluster.html. Once this is done, we are ready to start the kafka messaging system by running the following commands:

> cd $KAFKA_HOME
> bin/kafka-server-start.sh config/server.properties

To start testing kafka setup, Ctrl+Alt+T to open a new terminal and run the following command to create a topic "verification-topic" (a topic is a named entity in kafka which contain one or more partitions which are message queues that can run in parallel and serialize to individual folder in /var/kafka-log folder):

> cd $KAKFA_HOME
> bin/kafka-topics.sh --create --zookeeper 192.168.2.2:2181 --topic verification-topic --partitions 1 --replication-factor 1

The above command creates a topic named "verification-topic" which contains 1 partition (and with no replication)

Now we can check the list of topics in kafka by running the following command:

> bin/kafka-topics.sh --zookeeper 192.168.2.2:2181 --list

To test the producer and consumer interaction in kafka, fire up the console producer by running

> bin/kafka-console-producer.sh --broker-list localhost:9092 --topic verification-topic

9092 is the default port for a kafka broker node (which is localhost at the moment). Now the terminal enter interaction mode. Let's open another terminal and run the console consumer:

> bin/kafka-console-consumer.sh --zookeeper 192.168.2.2:2181 --topic verification-topic

Now enter some data in the console producer terminal and you should see the data immediately display in the console consumer terminal.

Friday, November 21, 2014

Create a passwordless SSH login to remote computers to automate launch of a zookeeper cluster

Passwordless SSH Login can be useful in situations, for example, when one likes to write a bash script that automatically setup or launch a zookeeper cluster. Suppose we want to ssh login to a computer at 192.168.2.4 without a password from a our client computer at 192.168.2.2, we can do so by creating a RSA pair of authentication key at 192.168.2.2 terminal:

> ssh-keygen -t rsa

In the terminal prompt, just press the ENTER key multiple times for each prompt. Once this is done, a public key rsa_id.pub is stored in the .ssh folder under the user root folder. Now ssh login to the 192.168.2.4 (password required at this point) to create the .ssh folder under the user root folder on that computer:

> ssh username@192.168.2.4 mkdir .ssh

The last step is to append the .ssh/rsa_id.pub file (which is the public key) from 192.168.2.2 to the .ssh/authorized_keys in 192.168.2.4 (password required at this point):

> cat .ssh/id_rsa.pub | ssh username@192.168.2.4 'cat >> .ssh/authorized_keys'

Now we can ssh login to 192.168.2.4 from the client 192.168.2.2 without password. For example, run the following command in the client 192.168.2.2 terminal:

> ssh username@192.168.2.4

Now we are ready to write a bash script to launch the zookeeper cluster which consists of the following networked computers:

192.168.2.1
192.168.2.3
192.168.2.4

First make sure that the zookeeper is setup in the cluster properly (follow instructions from this link: http://czcodezone.blogspot.sg/2014/11/setup-zookeeper-in-cluster.html and for storm at this link http://czcodezone.blogspot.sg/2014/11/setup-storm-in-cluster.html) and make sure the above steps of passwordless SSH login is repeated for 192.168.2.1 and 192.168.2.3 so that user can log into these two computers without password from the client 192.168.2.2. Now on the terminal of 192.168.2.2, create a start_zookeeper_cluster.sh script:

> touch start_zookeeper_cluster.sh
> gedit start_zookeeper_cluster.sh

In the start_zookeeper_cluster.sh that opens, enter the following lines:

ssh username@192.168.2.1 $ZK_HOME/bin/zkServer.sh start
ssh username@192.168.2.3 $ZK_HOME/bin/zkServer.sh start
ssh username@192.168.2.4 $ZK_HOME/bin/zkServer.sh start

Save and close the start_zookeeper_cluster.sh, and run the following command on 192.168.2.2 client terminal to make it executable:

> chmod +x ./start_zookeeper_cluster.sh

Now run the script to start the zookeeper cluster:

> ./start_zookeeper_cluster.sh

We can also write a stop_zookeeper_cluster.sh, start_storm_cluster.sh, stop_storm_cluster.sh in a similar way to automate the process.





Setup Storm in a cluster

To setup storm in a cluster, suppose we have the following computers networked together:

192.168.2.1
192.168.2.2
192.168.2.3
192.168.2.4

Let's say we use computer 192.168.2.2 and 192.168.2.4 to run the zookeepers which maintain states and communications for storm cluster. We also use 192.168.2.1 as the storm master node (i.e, the nimbus host) and 192.168.2.2 and 192.168.2.3 (i.e., the supervisor nodes) as the storm work nodes. Furthermore, let's suppose we work on 192.168.2.4 as a client which submit storm topology to the storm cluster.

Firstly we need to setup zookeeper in the cluster consisting of 192.168.2.2 and 192.168.2.4. Following this link for instructions to setup the zookeeper in a cluster: http://czcodezone.blogspot.sg/2014/11/setup-zookeeper-in-cluster.html

Next on computers 192.168.2.1, 192.168.2.2, 192.168.2.3, and 192.168.2.4 which forms the storm cluster, let's setup the storm using instruction for storm setup in a single machine from this link: http://czcodezone.blogspot.sg/2014/11/setup-storm-on-single-machine-running.html

Once the storm has been set up in the 4 computers, on each computer, navigate to the STORM_HOME/conf directory and edit the storm.yaml using the following commands:

> cd $STORM_HOME/conf
> gedit storm.yaml

In the storm.yaml, modify the settings as followings:

storm.zookeeper.servers:
  - "192.168.2.2"
  - "192.168.2.4"
storm.zookeeper.port: 2181
nimbus.host: "192.168.2.1"
storm.local.dir: "/tmp/storm-data"
java.library.path: "/usr/local/lib"
storm.messaging.transport: baketype.storm.messaging.netty.Context
supervisor.slots.ports:
 - 6700
 - 6701
 - 6702
 - 6703

Save and close the storm.yaml in each of the storm cluster computers. Now on the client computer (i.e. 192.168.2.4), create a .storm folder its user root folder and copy the updated STORM_HOME/conf/storm.yaml into the .storm folder created:
> cd $HOME
> mkdir .storm
> cp $STORM_HOME/conf/storm.yaml $HOME/.storm

Now on the master node computer 192.168.2.1, run the following command to start the master node:

> cd $STORM_HOME
> bin/storm nimbus

Now on the two supervisor node computer (192.168.2.2 and 192.168.2.3), run the following command to start the work nodes:
> cd $STORM_HOME
> bin/storm supervisor

At this point, the storm has been setup and running. To view the status of the storm cluster, choose one of the computer (or the client computer) and run the following command to start the storm web front ui:

> cd $STORM_HOME
> bin/storm ui

Now navigate to the http://localhost:8080 on that computer's web browser, you should see the storm cluster status

Now we are ready to submit a storm topology, on the client computer 192.168.2.4, run the following command to submit the topology
> cd $STORM_HOME
> bin/storm jar [fullPathToTopoloyJarFile] [mainClassInJar] [arg0] [arg1] ...

Now navigate back to the http://localhost:8080, you should see the submitted topology running in the cluster.

Wednesday, November 19, 2014

Setup ZooKeeper on a single machine running Ubuntu 14.04 LTS

This post shows how to set up ZooKeeper on a single machine running Ubuntu 14.04 LTS.

Firstly download ZooKeeper from the following link:

http://mirror.nus.edu.sg/apache/zookeeper/zookeeper-3.4.6/zookeeper-3.4.6.tar.gz

Unzip the downloaded file and put the unzipped folder in a folder, say the following
$HOME/Documents/Works/ZooKeeper/zookeeper-3.4.6

Now go the the $HOME directory and run the following command to open the .bashrc file in terminal:

> gedit .bashrc

In the .bashrc file, add the following line to the end:
export ZK_HOME=$HOME/Documents/Works/ZooKeeper/zookeeper-3.4.6

Save and close the .bashrc file, run the following command to update the environment var:

> source .bashrc

Now run the following command to go to the $ZK_HOME/conf directory

> cd $ZK_HOME/conf

Run the following command to create the configuration zoo.cfg:

> touch zoo.cfg
> gedit zoo.cfg

In the zoo.cfg opened, add the following lines:

tickTime=2000
dataDir=/tmp/zookeeper
clientPort=2181

Save and close zoo.cfg, go back to the ZooKeeper home directory:

> cd $ZK_HOME

Run the following command to start the zookeeper on the machine:

> bin/zkServer.sh start

Run the following command to check the java process running:

> jps

Run the following command to check the status of zookeeper:

> bin/zkServer.sh status

Run the following command to stop the zookeeper:

> bin/zkServer.sh stop



Tuesday, November 18, 2014

Setup Maven on Ubuntu and MacOS

This post contains how to set up maven on Ubuntu and MacOS as well as finding their installation location. On Ubuntu, run the following command in the terminal:
$mvn 
The printout will indicate whether maven is installed or not. If not, run the following command to install:
$sudo apt-get install maven2
After maven is installed, its home directory is at /usr/share/maven2 (depending on your version)
To install maven on MacOS, run "$mvn --version" to check whether it is installed. If not, run the following command in the terminal to install:
$brew install maven
After the installation, to find the installation path of maven, type the following command:
$mvn --version

Install Oracle JDK 8 on Ubuntu 14.04 LTS

Due to license issue, Ubuntu 14.04 LTS does not come with Oracle JDK. you can check the current java installed by running:

$java -version

To install the latest Oracle JDK 1.8 and set as default JDK on Ubuntu. First download the JDK 1.8 from the Oracle download page:


or


Download the jdk-8u25-linux-x64.rpm (assuming that you have a 64bit Ubuntu installed). As Ubuntu is based on Debian, we need to convert the *.rpm to *.deb fileformat. To do so, install the alien using the following command line in Ubuntu terminal:

$sudo apt-get install alien

After the alien is installed, cd to the download folder containing the jdk-8u25-linux-x64.rpm. Run the following command line:

$alien -k jdk-8u25-linux-x64.rpm --scripts

After the above command line returns, the user should find the jdk-8u25-linux-x64.deb in the same folder. Now run the following command line to install JDK:

$sudo dpkg -i jdk-8u25-linux-x64.deb

After the JDK 1.8 is installed, open the .bashrc file in the $HOME directory:

$cd $HOME
$gedit .bashrc

In the .bashrc opened, add the following lines to the end:

export JAVA_HOME=/usr/java/jdk1.8.0_25/
export PATH=$JAVA_HOME/bin:$PATH

Save and close the .bashrc, now run the following command to update the environment var:

$source .bashrc

Done. we can check the current JDK on Ubuntu to confirm that the current version is indeed Oracle JDK 1.8 by running the following command:

$java -version

which should prints the following lines:

java version "1.8.0_25"
Java(TM) SE Runtime Environment (build 1.8.0_25-b17)
Java HotSpot(TM) 64-Bit Server VM (build 25.25-b02, mixed mode)



Tuesday, July 9, 2013

Add TinyXml support to Qt Application

Download and unzip the tinyxml in the project folder of the Qt application. cd to the Qt project folder and enter the following command in the command prompt:
$qmake -project

This will generate the xxx.pro (where xxx refers to the name of the Qt project folder), in the xxx.pro insert the following lines below the line starting with "TARGET = ":

DEPENDPATH += . tinyxml
INCLUDEPATH += . tinyxml

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}




Step-by-step for installing QwtPlot on Ubuntu Linux

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 Qt
Check whether Qt has been installed on the target linux machine, by entering the following in the command prompt:
$qmake -help

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

Step 4: Install QwtPlot
To install QwtPlot, download the software package qwt-6.0.1.zip from 

Unzip the package (to unzip, if you are using Ubuntu, right-click the zip file and click "Extract Here" from the context menu). Next from the terminal, cd to the unzipped folder "qwt-6.0.1", and run the following command:
$qmake
This will generate the Makefile require to build QwtPlot, next run the command:
$make
This will build the QwtPlot, next run the command:
$sudo make install
This will install QwtPlot (when using ubuntu, the installed directory can be found at usr/local/qwt-6.0.1). The final step is to add the QwtPlot export statement into the .bashrc file in the /home/[username] directory ([username] refers to the linux login id). To add the export statement, run the following commands in the terminal:
$cd /home/[username]
$ls -a
$gedit .bashrc
In the .bashrc file that opened, add the following two lines to the bottom of the file
export QWT=/usr/local/qwt-6.0.1
export LD_LIBRARY_PATH=$QWT/lib:$LD_LIBRARY_PATH

Step 5: Build Qt application using QwtPlot
To build the Qt application with QwtPlot data visualization, enter the following command with the  Qt project folder:
$qmake -project

This will build the xxx.pro (where xxx refers to the project name), in the xxx.pro, just below the line starting wtih "INCLUDEPATH" (or below the line starting with "TARGET=" if line starting with "INCLUDEPATH"  is not in xxx.pro), insert the following lines:
QWT_VER_MAJ      = 6
QWT_VER_MIN      = 0
QWT_VER_PAT      = 1
QWT_VERSION      = $${QWT_VER_MAJ}.$${QWT_VER_MIN}.$${QWT_VER_PAT}

QWT_DIR = /usr/local/qwt-$$QWT_VERSION 

LIBS += -L$$QWT_DIR/lib -lqwt
INCLUDEPATH += $$QWT_DIR/include

Now run the following command to build the project
$qmake
$make