Thursday, April 28, 2011

Boost - Building from source

Boost is a comprehensive and portable libraries. It provides libraries from Math, IO, Network, etc... You can check out the list of libraries here. The main reason for my interest in this libraries is their portability. They had figured out the the x86 and x64 portability issues on these libraries. All you need is to compile the source with appropriate switches for your code. Moreover, this is a free library that can be used both commercial and non-commercial usage.

How to build from source

Follow the step to build the Boost from source.

1. Download latest version here

2. Unzip/untar the downloaded source

3. Use command prompt to run bootstrap.bat for Windows and for Linux

5. Then, run the following bjam for build

Bjam linux 32 bit with GCC

./bjam --build-dir="/root/boost_1_46_1/lib" --build-type=complete toolset=gcc address-model=32 architecture=x86 link=static --with-thread --with-serialization

Bjam Window commands 64 bit with MSVC 10

bjam --build-dir="C:\Boost\boost_1_46_1\lib" --build-type=complete toolset=msvc-10.0 address-model=64 architecture=x86 link=static --with-system --with-date_time --with-regex

Important switch to take note


It allows you to specify the output of the libraries builds


It allows you to set the compile toolset for the source. For my example, it uses gcc and msvc-10.0


It allows you to defined to compile 32/64 bits libraries


It allows you to build static or shared libraries


It allows you to specify which specific to be built. For example, --with-system --with-date_time --with-regex means to build only system, data_time and regex libraries


Sunday, April 10, 2011

MS Virtual PC - Compact Dynamic Virtual Hard Disk For Linux Guest OS

If you are using Microsoft Virtual PC with dynamic virtual hard disk, you will realize that the size of the dynamic hard disk grow over time and it will not shrink.

MS Virtual PC provide a function to compact hardisk

But prior to use that function, you have to prepare the disk for compaction. Their preparation is simply mean zeroing your hard disk. MS Virtual PC can only reclaim zero-ed hard disk space.

For Linux, do the following

1. Start up your Linux virtual machine

2. At the console in any directory level, type

cat /dev/zero >

This will eventually fill up your virtual hard disk with 0 in This will take some time depends on the size of your hard disk.

3. When it is done, type the following commands

sync; sleep 30;sync

This is to make sure the data is written to disk

4. Then, type


This is to remove the zero file. By doing the above operation, it filled the virtual disk with zero data.

5. Shut down the Linux Virtual Machine and run the Compact Tools at MS Virtual PC

The above helps me to shrink a 20GB virtual hard disk to 11GB virtual hard disk

For information how to compact a dynamic hard disk for Window Guest OS, see

Linux - Check Shared Object Compile Version

If you want to check whether a shared object (.so) is 32 bits or 64 bits compiled, you can use the following commands

1. file

This file command will output the file type of the given file. It will work for .so files. Look for ELF XX-bit in the output. It will tell you whether the file is 32 bits or 64 bits compiled.

2. readelf -h

Thie readelf command will output the information about elf files. Look for Class: ELFXX where XX will tell you whether the file is 32 bit or 64 bit compiled

Please note that readelf -h works for archive files (.a) as well.

For windows, see Dumpbin command

Thursday, April 7, 2011

Linux - RPM

RPM is one of the tools for linux package install. Below are some useful commands

Please replace XXX with your rpm package name

1. Install to default folder

rpm -i XXX.rpm

2. Install with Relocation

rpm -i --prefix=/ur/path XXX.rpm

3. Check whether a rpm package can be relocated

rpm -qpi XXX.rpm | grep Relocations

4. Check for installed package in machine

rpm -qa | grep XXX

5. Uninstall a package

rpm -e XXX

6. Upgrade a package

rpm -U XXX.rpm

Tomcat - removing server info

Below are the steps to remove Tomcat Server Information 1. Make sure Tomcat is not running 2. Navigate to "Tomcat Installation"...