Sunday, February 17, 2013

How to build llvm from source on ubuntu 12.04

So I needed to build the latest llvm i.e. version 3.2 from source today. In this post I will describe the steps for Ubuntu 12.04.

First download the llvm source package from this link. I downloaded the x86 version because I am running 32 bit version of Ubuntu(aka i386).
Link: 32 bit

You can download the x86_64 version if you are running 64 bit Ubuntu(aka amd64).
Link: 64 bit

Put the downloaded .tar.gz archive in a convenient location. I put mine on ~/opt. Then extract the archive via this command.

cd ~/opt
tar xvzf clang+llvm-3.2-x86-linux-ubuntu-12.04.tar.gz

Now you will have a directory named LLVM. Go to the llvm directory.

cd LLVM
cd llvm
Now here comes the tricky part. The first time I ran this command


./configure --enable-optimized

and was greeted with the following error at the end:

configure: error: Selected compiler could not find or parse C++ standard library headers.  Rerun > with CC=c-compiler CXX=c++-compiler ./configure ...
The main purpose of this post is so that others can get rid of this specific error. Run the following command to get rid of the above error. You should have clang installed on your computer for this to work.

sudo apt-get install clang
./configure --enable-optimized CC=/usr/bin/clang CXX=/usr/bin/clang++

We have run the configuration script. Next step is to run the make command to start the building process. I should warn you that this is going to take a lo..ng time to finish.

make
After make finishes building run this final command to install.

sudo make install
References:

Saturday, February 16, 2013

Quickly open current directory in nautilus from commandline

Say you are doing some work on commandline and you would like to open your current directory on nautilus to look around graphically. It can be quite useful sometimes. In this post I will tell you how. Add this line to the end of your .bash_aliases file.


alias n.='nautilus .'

Save it and run this command to update.


source ~/.bash_aliases

Now check if it works and let me know in the comments.

Friday, February 15, 2013

Your shared library and LD_LIBRARY_PATH

Libraries which are loaded dynamically at runtime are called shared object library in linux. They have .so extension. LD_LIBRARY_PATH is the path where your linux os looks for shared object library. Suppose you have your own libraries in the folder ~/mysharedlibs. In order to be able to use the libraries add this code to your .bashrc file.



if [ -d ~/mysharedlibs/ ];
then
    LD_LIBRARY_PATH=~/mysharedlibs/:$LD_LIBRARY_PATH
fi 

export LD_LIBRARY_PATH

References:

Test syntax highlighting

Testing prismjs syntax highlighting.


var foo = "bar", baz = 5;



# highligted with prismjs
print "Python works too"