OpenCV 2.4.2 in Ubuntu

I recently built OpenCV 2.4.2 for Ubuntu since I needed that for my project and the version available in Ubuntu was quite dated. I got quite a few pointer on how to build packages and upload them to launchpad PPA here.

To install OpenCV 2.4.2 in Ubuntu, give the following commands:

$ sudo apt-add-repository ppa:bobby-prani/opencv-2.4.2
$ sudo apt-get update
$ sudo apt-get install opencv

C/C++ auto complete in emacs using clang in Debian/Ubuntu

I got so accustomed to using Visual Studio 2010 over the course of my internship, that I seriously was missing it while coding in Linux. I knew there were tools available like libclang+vim etc., but they never seemed complete. So finally I sat down and got auto-complete working with emacs in Ubuntu Linux(Note: This should also work in other distributions, but I’ve only tested it on Debian testing and Ubuntu 12.04).

I also got the browsing mode setup which enables me to jump to definitions, see the references of functions etc., A complete setup for browsing source is here.

Here are the steps:

1. Install emacs, emacs-goodies, global, clang, auto-complete

sudo apt-get install emacs emacs-goodies-el global clang auto-complete-el cscope-el

2. Download this emacs conf file and copy it to ~/.emacs

3. Copy the contents of this file into ~/.emacs.d/

4. generate global tags in the rootsource directory by issuing the command

gtags -v

5. Done!

emacs_ftw

Auto complete in emacs using clang
* To search for tags, use M-.
* To search for symbols, use M-]
* To search for function references, use M-[
* To go back to where you were, use M-*

If there are any errors/suggestions, please let me know in the comments. Thanks!

update 11/08/2012: added cscope-el

update 1/30/2014: source code browsing in emacs is much simpler now thanks to global. Check it out: https://github.com/leoliu/ggtags

road trip

“Are you afraid of death?, my friend” asked my co-passenger. Not quite amused by the question and not understanding what he was getting at, I replied with a stern ‘No’. I knew that picking up hitchhikers was a bad idea. But the thought of a long boring journey, alone, made me do what I would not usually have done. I hoped I would not repent it. This new friend was shuffling around in his seat, as if trying to get something out of his pocket. I caught the glitter off a metal object in his coat. I thought about the worst possible situation. This seemed to be it and that object seemed to be a gun.

“What are you doing?”, I shouted at him, startling him and making him fumble a bit more. “Jesus, why the fuck are you shouting?”, he shouted back. He found what he was looking for. His hand slowly took the gun out of his pocket. I found his use of Jesus and fuck in the same sentence a bit funny.

It was a metal box which had some weed rolled up.

All calm now, the hitchhiker said “If you are not afraid, I don’t think you would mind driving high” and handed me a lit joint. It was an interesting trip that one, sure did not repent it.

not A True Story.

llvm

It is great to see innovation in the compiler space.

I happened to use LLVM for a compiler project and it is amazing to see how flexible the framework is.

LLVM was created by Chris Lattner at UIUC in the course of his PhD research.
It really undermines the need to be a very good programmer to create a project on that scale. Apple employed Chris to adopt LLVM to MAC OS X as they were stuck with GCC version 4.2 as the later version of GCC moved to GPL v3.

The Clang frontend recently has advanced enough to be able to build a linux kernel. Also XCode includes LLVM-clang.

Apparently clang is much faster at building code and also gives more meaningful error messages. Though the performance difference in terms of actual binary is not huge, the scope for improvement is very high as it is easier to implement optimizations than in GCC.

The BSD projects have been looking for quite some time to adopt a compiler with a more appropriate license, since the license of GCC is restrictive when compared to BSD license. There were quite some BSD licensed compiler projects in between, most notable PCC. But I am betting on LLVM to take the place of GCC in the BSD world pretty soon.

It is always good to have competing projects just to keep the people involved on their toes and foster innovation.

linux kernel with icc – the intel c compiler

Found an interesting site which gives info about building a linux kernel with icc. I am currently working a lot with icc and was looking at how good/better it is than gcc.

The result: not that great. Most of Intel’s compiler work is at present directed towards Itanium. I was hoping that since icc does not have to support as many architectures as gcc, it would have many platform specific optimizations. But that does not seem to be the case.

May be some day I will get around to building the kernel with icc and updating the kernels…