Friday, May 30, 2014

Managing different versions of a software - update-alternatives

Managing different versions of a software in Ubuntu is made easy by update-alternatives. For example, assume having different versions of eclipse in Ubuntu.

The eclipse can be installed from the tar balls available from eclipse download page. Juno Download page. Indigo Download Page.

Move the downloaded the tar balls to /opt and unzip them. (/opt - just a directory for optional packages)

$cd /opt
/opt$sudo mv ~/Downloads/eclipse-cpp-juno-SR2-linux-gtk-x86_64.tar.gz .
/opt$sudo tar xzvf eclipse-cpp-juno-SR2-linux-gtk-x86_64.tar.gz
/opt$sudo mv eclipse eclipse_juno
/opt$sudo mv ~/Downloads/eclipse-cpp-indigo-SR2-incubation-linux-gtk-x86_64.tar.gz .
/opt$sudo tar xzvf eclipse-cpp-indigo-SR2-incubation-linux-gtk-x86_64.tar.gz
/opt$sudo mv eclipse eclipse_indigo

The launcher executable (eclipse.exe) for the installed versions of eclipse would be in the respective install folder. I.e., In our case there will be a launcher executable (eclipse.exe) inside "/opt/eclipse_juno/" and "/opt/eclipse_indigo".

Now to manage the launch of these two versions of eclipse, we use the "update-alternatives" as shown below.

$sudo update-alternatives --install /usr/bin/eclipse eclipse /opt/eclipse_juno/eclipse 20
$sudo update-alternatives --install /usr/bin/eclipse eclipse /opt/eclipse_indigo/eclipse 10

Now to choose between versions, use "update-alternatives --config".

$ sudo update-alternatives --config eclipse
There are 2 choices for the alternative eclipse (providing /usr/bin/eclipse).

Selection Path                        Priority  Status
------------------------------------------------------------
* 0       /opt/eclipse_juno/eclipse   20        auto mode
  1       /opt/eclipse_indigo/eclipse 10        manual mode
  2       /opt/eclipse_juno/eclipse   20        manual mode

Press enter to keep the current choice[*], or type selection number:

By giving the selection number, the desired version shall be made set for launching.

Now we see the "update-alternatives --install" in detail. Consider the following command we issued above.

$sudo update-alternatives --install /usr/bin/eclipse eclipse /opt/eclipse_juno/eclipse 20

Here the number '20' is the priority for the version of the launcher we configure for alternatives. Higher the number higher the priority.

'/opt/eclipse_juno/eclipse' is the launcher we configure for alternatives.

'eclipse' is a symbolic link to be created in /etc/alternatives/. This symbolic link will point to the launcher we configure. Here it will be '/opt/eclipse_juno/eclipse'.

'/usr/bin/eclipse' is a symbolic link to '/etc/alternatives/eclipse'.

How it works?

'/usr/bin/eclipse' will always link to '/etc/alternatives/eclipse'. And '/etc/alternatives/eclipse' will change its link to the launcher we configure through "update-alternatives --config".

Wednesday, May 28, 2014

TV as display for Laptop through HDMI

TVs can be used as the displays for laptops using HDMI. For this, the TV and the laptop should have the HDMI port supported. And we need a HDMI cable.

I have ASUS X550LD laptop with Ubuntu 14.04 LTS on it and Sony Bravia KDL-40HX750. The laptop and the TV is connected through a HDMI 1.4a cable. To enable the display following are steps done.

Open the system display settings.

In display settings, we can see the built-in display enabled.

Select the TV display (Sony 40" in my case).

Switch-on the TV display.

Also set the launcher placement to TV.

Now switch-off the built-in display.

And apply the settings.

Now the display would be on the TV.

We may have to do some settings for the sound from TV. Open the sound settings.

There we can find the list of audio devices.

We have to select the 'HDMI / DisplayPort 2' audio device.

In my case, I found the sound setting as follows.

The 'HDMI / DisplayPort 2' audio device is not listed. I muted the laptop speakers and restarted the laptop. Then I got the list including 'HDMI / DisplayPort 2' audio device.

Tuesday, May 27, 2014

Makefile - Checking Build Compiler Version

Building executable from sources is made easy by Makefiles. If a build has to be done by checking the version of the build compiler, then the Makefile can be altered for that.

For example, building C sources using GCC compiler. If the C sources require the C++11 standard supported compiler, then the GCC compiler to be used should be greater than or equal to GCC-4.7. If the build environment has the GCC of version lesser than 4.7, then the build will fail.

For this case, the Makefile can be altered with the following check for GCC version:

GCCMAJORVERSIONGTE4 := $(shell expr `gcc -dumpversion | cut -f1 -d.` \>= 4)
GCCMINORVERSIONGTE7 := $(shell expr `gcc -dumpversion | cut -f2 -d.` \>= 7)

all:
ifeq ($(GCCMAJORVERSIONGTE4)$(GCCMINORVERSIONGTE7), 11)
        @echo BUILD
else
        @echo NO BUILD
endif

Wednesday, February 26, 2014

Taglist - A VIM Plugin for browsing the source code

Browsing the source codes in VIM can be made easy using the plugin "Taglist". It supports many programming languages like C, C++, C#, Python, Java etc. (for the complete list refer An intro on Taglist).

Download and install the taglist plugin for VIM from,
http://vim-taglist.sourceforge.net/

After installing the plugin, we can set taglist variables in the '~/.vimrc' file based on our requirement. For the details on taglist variables, refer taglist usage.

Some taglist variables in my '~/.vimrc',

"Set to automatically open the taglist window on VIM startup
let Tlist_Auto_Open = 1
"Set for the vim to exit when only the taglist window is present
let Tlist_Exit_OnlyWindow = 1
"Set for reducing the number of empty lines in the taglist window
let Tlist_Compact_Format = 1

Thursday, December 19, 2013

Playing .mkv files with DTS audio codec on Sony Bravia

I have already blogged on how to play mkv files on "Sony Bravia HD 3D LED KDL-40HX750" TV. But for playing mkv files with DTS audio codec, there is one extra step we have to do before converting the mkv files to the m2ts files.

We need to convert the DTS audio codec inside the mkv file to AC3 audio codec. This is because, the DTS audio codec is not supported by the Sony Bravia KDL-40HX750. I used the script mkvdts2ac3.sh by Jake Wharton and Chris Hoekstra. This script converts the DTS track in the mkv file to AC3 track. And the usage of this script is very simple.

Get the script mkvdts2ac3.sh (on my ubuntu 12.04 LTS) as follows:

wget https://raw.github.com/JakeWharton/mkvdts2ac3/master/mkvdts2ac3.sh

Give the mkv file with the DTS audio codec as the input to the script as shown below:

The conversion starts and gets completed by displaying the summary on the conversion process as shown below:

Now the mkv file can be converted to the m2ts file with only the AC3 audio codec.

Thus obtained m2ts file can be played on "Sony Bravia HD 3D LED KDL-40HX750" TV.

Thursday, July 25, 2013

Patents search

'www.freepatentsonline.com' can be used for Patents search. In this site, we could list down the patents based on several search conditions. I.e. If we want to list down the patents filed by indian inventors, we should use ICN/IN in the search term. ICN stands for 'Inventors Country Name' and IN stands for 'India' (Country Code Table). Similarly the patents database can be searched for several other conditions.

For example, to search patents for 'heterogeneous multiprocessor' filed by indian inventors in-between the period 2007 to 2009, the search condition should be as follows:

APD/01/01/2007->12/31/2009 AND ICN/IN AND (heterogeneous AND multiprocessor)

The links listed below can be used to get introduced to the search condition keywords:
Also consider whether you would require 'Word Stemming' option enabled for your search. By default, it is enabled. Enabling this for a search term, it would search for all variants of a search term. If you would like narrow down the search in particular to your search term, then you just disable it. (for more info on this)

Wednesday, April 3, 2013

lldb for llvm-3.1


We had a cross-compiler tool-chain based on llvm-3.0. And we needed a debugger for the target. We chose lldb and we ported it for the target architecture. (Click here for somemore details). We used lldb svn trunk revision '142603'. We were able to integrate this revision of lldb into the llvm-3.0.

Recently the cross-compiler tool-chain has been upgraded to llvm-3.1. Since lldb depends on llvm, the lldb also has to be upgraded to a revision that would get build with llvm-3.1. (Note: The lldb svn trunk revision '142603' that we used with llvm-3.0 cannot be used with llvm-3.1. This is because lldb uses few modules of llvm for some functionalities such as expressions evaluation, disassembling. Hence changes in llvm would be reflected in lldb as it grows).

Till llvm-3.1, there is no sync between a llvm release and the lldb. And hence finding a right svn trunk revision of lldb that would work with llvm-3.1 is a little time-consuming task. The lldb trunk revisions are traversed to find the right revision that would work with llvm-3.1. And I found that lldb svn trunk revision 161210 works with llvm-3.1 after the following tweaks.

Change #1:
File: lldb/include/lldb/Expression/RecordingMemoryManager.h
Line: 284
Incorporated the changes from svn revision-164563 of this file. Added the following code:

    //------------------------------------------------------------------
    /// Passthrough interface stub
    //------------------------------------------------------------------
    virtual void *getPointerToNamedFunction(const std::string &Name,
                                            bool AbortOnFailure = true) {
        return m_default_mm_ap->getPointerToNamedFunction(Name, AbortOnFailure);
    }

Change #2:
File: lldb/lib/Makefile
Line: 60
Incorporated the changes from svn revision-164703 of this file. Removed the following line

      clangIndex.a \ 

Change #3:
File: lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
Line: 1519
Incorporated changes from svn revision-164563 of this file. Changed the following line

        case DW_TAG_APPLE_Property:
to
        case DW_TAG_APPLE_property:

Change #4:
File: lldb/source/Symbol/ClangASTContext.cpp
Line: 361
Incorporated the changes from svn revision-164563 of this file. Changed the following line

    Opts.NoInline = !Opt;
to
    Opts.NoInlineDefine = !Opt;

After the above mentioned tweaks, the lldb is successfully ported to our target.

Saturday, March 16, 2013

Sony Bravia TV - mkv files and files > 4 GB

With "Sony Bravia HD 3D LED KDL-40HX750" TV I faced the problem of playing '.mkv' files. Sony Bravia didn't support the .mkv file formats.

The other problem I faced is, playing the media files greater than 4 GB in size. The flash drive I used had the fat32 file system in which a single file cannot be more than of 4 GB in size.

Here I have summed up the solutions I found on internet to overcame the above two problems.
  1. tsmuxer
  2. Serviio DLNA media streaming server.

Playing the .mkv files in Sony Bravia

mkv is a multimedia container file format. This shall be converted to m2ts (MPEG-2 Transport Stream) multimedia container file format. Sony Bravia supports the m2ts file format.

tsmuxer (Transport Stream Muxer) shall be used to mux the mkv file format to the m2ts file format. 


And I used the downloaded tsmuxer (on my ubuntu 10.04 lucid) as follows:

$mkdir tsmuxer
$cd tsmuxer/
$mv ../../Downloads/tsMuxeR_1.10.6.tar.gz .
$tar zxvf tsMuxeR_1.10.6.tar.gz 
$./tsMuxerGUI 

The tsMuxer GUI would look like as shown below.

In the input tab, add the mkv file to be muxed to m2ts file. In output, select the option "M2TS muxing" and point to the destination folder into which the muxed file to be placed. Then click "Start muxing".

Now thus obtained m2ts file can be played by the Sony bravia.

Playing the media files greater than 4 GB in size

For this there are two solutions for Sony Bravia KDL-40HX750.
  1. Format the USB flash drive for exFAT format. 
  2. Serviio DLNA media streaming server.

1. Format the USB flash drive for exFAT format. 

Sony Bravia KDL-40HX750 supports exFAT file system. And in exFAT filesystem we can have files greater than of 4 GB in size. 

Format the USB flash drive for exFAT file system. Since I couldn't format the USB flash drive to exFAT in my Ubuntu system, I used a windows XP (a service pack has to be installed to support exFAT) system to format my USB flash drive for exFAT file system.

There-after, I am able to use the USB flash drive with my Ubuntu system by using the fuse-exfat package. The fuse-exfat package was installed in my system as follows:

$sudo add-apt-repository ppa:relan/exfat
$sudo apt-get update
$sudo apt-get install fuse-exfat

After installing the fuse-exfat package the USB drive with exFAT file system can be mounted as follows:

$sudo mkdir /media/exfat
$sudo mount -t exfat /dev/sdc1 /media/exfat

Now the read and write on the USB flash drive can be done. After usage, the USB flash drive can be unmounted as follows:

$sudo umount /media/exfat

Now with this solution, I am able to play the media files greater than 4 GB in size.

2. Serviio DLNA media streaming server.

Sony Bravia KDL-40HX750 is DLNA enabled. The media files can be streamed from the computer using the Serviio DLNA media streaming server. Given that the TV and the computer are connected to a router, now the TV would be able to access the media content from the computer.

I downloaded the Serviio for my ubuntu system from the link given below:


Installed and started the servio console as follows:

Extracted the downloaded the package.

$tar zxvf serviio-1.1-linux.tar.gz 

Created the file "serviio.conf" in the directory "/etc/init/" with the following content in it.

start on started networking
script
   /home/ck/serviio-1.1/bin/serviio.sh
end script

Then on terminal do the following:

$sudo /etc/init.d/networking restart
$sudo start serviio
$cd serviio-1.1/
$bin/serviio-console.sh 

The serviio console would look like as shown below. The Status tab would show the devices connected to the server.

For sharing the media files through the server, include the path to the media files in the Library tab as shown below.

Saturday, March 9, 2013

Enable wired and wireless network connections in Ubuntu 12.04


Recently upgraded to Ubuntu 12.04 from Ubuntu 10.04. After the upgrade, both the wired and wireless network connections didn't work.

I have summarized what I did to enable both the network connections along with the reference which I followed.

Wired Network Connection:

Step #1: Removed the package "resolvconf" and restarted the NW:

$sudo apt-get remove --purge resolvconf
$sudo /etc/init.d/networking restart

Ref: http://ubuntuforums.org/showthread.php?t=1973604

Step #2: Edited the /etc/network/interfaces file to contain only the following two lines:

auto lo
iface lo inet loopback

Ref: http://ubuntuforums.org/showthread.php?t=1943143

Wireless Network Connection:

Note: I have Broadcom Corporation BCM4318 [AirForce One 54g] 802.11g Wireless LAN Controller.

Step #1: Did the following:

$sudo apt-get install linux-firmware-nonfree
$sudo modprobe -r b43
$sudo modprobe b43

Ref: http://askubuntu.com/questions/171427/wireless-isnt-working-in-12-04

Note: 
1. If you get the error "E: Unable to fetch some archives" while running the command "sudo apt-get install linux-firmware-nonfree" mentioned above, then run the command "sudo apt-get update" before doing the above step.

Ref:http://www.linuxquestions.org/questions/linux-newbie-8/icky-ubuntu-cannot-download-packages-767779/

2. If you get the following warning when you run "sudo modprobe -r b43" and "sudo modprobe b43", then just rename the files "/etc/modprobe.d/bad_list" and "/etc/modprobe.d/ndiswrapper" to "/etc/modprobe.d/bad_list.conf" and "/etc/modprobe.d/ndiswrapper.conf" respectively.

WARNING: All config files need .conf: /etc/modprobe.d/bad_list, it will be ignored in a future release.
WARNING: All config files need .conf: /etc/modprobe.d/ndiswrapper, it will be ignored in a future release.

With the above set-up the wireless network connection would be up. But on restarting the system, the wireless network connection won't be up. For the wireless connection to be up automatically, the following has to be done.
  1. Edit the /etc/modprobe.d/blacklist.conf file. The /etc/modprobe.d/blacklist.conf file has the list of modules that should be prevented from loading at boot time. Comment out the following line:
    • blacklist bcm43xx
  2. Edit the /etc/modules file. The /etc/modules has the list of modules that would be loaded at boot time. Add the following line at the end of the file.
    • b43
Ref: http://askubuntu.com/questions/90067/how-do-i-get-my-wireless-to-automatically-start-after-reboot

Friday, August 10, 2012

How to free a port that is bond by a process in linux?


First find the proces ID (pid) of the process that uses the port.

For example, to free the port '51000', first find the pid of the process that uses the port '51000'. Use the command 'netstat -tulpn' for the same.
$netstat -tulpn
(Not all processes could be identified, non-owned process info
 will not be shown, you would have to be root to see it all.)
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name
tcp        0      0 0.0.0.0:33660           0.0.0.0:*               LISTEN      -               
tcp        0      0 0.0.0.0:24800           0.0.0.0:*               LISTEN      1640/synergys   
tcp        0      0 0.0.0.0:111             0.0.0.0:*               LISTEN      -               
tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN      -               
tcp        0      0 127.0.0.1:631           0.0.0.0:*               LISTEN      -               
tcp        0      0 0.0.0.0:51000           0.0.0.0:*               LISTEN      11056/sim    
tcp6       0      0 :::445                  :::*                    LISTEN      -               
tcp6       0      0 :::139                  :::*                    LISTEN      -               
tcp6       0      0 :::22                   :::*                    LISTEN      -  
Using the command 'netstat -tulpn', we found that the 'pid' of the process that uses the port '51000' is '11056'. Now we have to kill the process that binds to the port '51000'. Issue the following command for the same.

$sudo kill -9 11056

On doing the above, the port would be freed.

Saturday, July 28, 2012

On linkers


Linker is a program that converts the object files into executables and shared libraries.

What a linker does? can be summarized into the following steps:
  • Parse options on the command line
  • Parse link scripts to read commands of linking
  • Symbol resolution
  • Relocation of instructions, data, symbols and sections
  • Output the linked file

Let's see the working of some existing linkers such as GNU ld, gold and MCLinker.

GNU ld
In the linking flow of GNU ld, the following steps are done iteratively:
  • Read and load the input files.
  • Do format checking.
  • Perform symbol resolution.
  • Apply relocation.

gold
gold separates the linking processes into two stages as follows:
  • stage 1: Do the following steps iteratively until all the files are read.
    • Read and load the input files.
    • Resolve symbols while checking the formats of the input files.
  • stage 2: Perform relocation in parallel.

MCLinker
MCLinker separated the linking processes into three stages as follows:
  • stage 1: Read and load input files. Check the formats.
  • stage 2: Symbol resolution.
  • stage 3: Perform relocation.

Click here for the reference of the above discussed linkers.
Click here for the what and how of linkers by Ian Lance Taylor.

Tuesday, July 3, 2012

Packager for binaries on any UNIX-compatible system


You may require to bundle the binaries built on any UNIX-compatible system for distribution.

For example, say, you have built a compiler using GCC compiler generation framework. And you need to distribute the built compiler binaries to some user. That means here you are required to distribute your gcc compiler installation directory to the user. How would you do that?

You can make a tar of the installation directory and distribute it to the user. But here you have to educate the user on how to untar and where to untar the provided tar file. And this way the user has to put some "extra" effort for using the binary distributed to him. Wouldn't it be better to provide the user with a self-extracting package of binaries?

Yes, you can provide the user with a self-extracting package of binaries. And the user has to just run it to extract the binaries into his desired directory. How to create a self-extracting package of binaries?

There is tool called "makeself". This is a very simple tool that does the job for you. Install this tool in your system and use it for creating the self-extracting package of binaries. For more information on "makeself", refer http://megastep.org/makeself/.

So for our example, assuming "myCompiler" as the installation directory to be distributed, create the self-extracting package "myCompiler.run" as follows:

makeself.sh --notemp myCompiler myCompiler.run "myCompiler generated from GCC framework" echo "myCompiler has been installed"

Sunday, June 10, 2012

Monday, May 7, 2012

Tuesday, June 7, 2011

How compiler tool chain handles symbols defined globally?

What happens when the following files are compiled (Lets take GNU C Compiler 'gcc-4.4.3' for this discussion) together? Note, both the files have the same symbol 'g_Var' declared globally.

file01.c
--------
int g_Var;

int main()
{
    g_Var = 4;

    vFunction ();

    if (8 == g_Var)
    {
        printf ("Passed\n");
    }
    else
    {
        printf ("Failed\n");
    }

    return 0;
}

file02.c
--------
int g_Var;

void vFunction()
{
    g_Var = 8;
}

Yes, the compiler tool chain (that would include the compiler, assembler and the linker) would compile successfully. And on execution, the result would be "Passed".

A further read on this article is required only if you wonder "why didn't the compiler tool chain shout for multiple definition of symbol 'gVar' during linking?"

The compiler tool chain didn't shout so because the compiler tool chain considers uninitialized global symbols as common (also called communal) symbols.

What is a common symbol?

A common symbol is symbol that defines a common data area that would be shared by symbols declared/defined in different source files. And the common symbol defined by two or more source files indicates the head address of a common data area.

So the symbol 'g_Var' in files file01.c and file02.c shares the same data area.

Let's see first how the compiler handles the symbol in files file01.c and file02.c. This can be done by probing the assembly files generated by the compiler for the files file01.c and file02.c respectively.

On providing the following on the command prompt, we get the assembly files file01.s and file02.s.

$gcc file01.c file02.c -S

In file01.s, we can see the following:

.file   "file01.c"
        .comm   g_Var,4,4

In file02.s, we can see the following:

.file   "file02.c"
        .comm   g_Var,4,4

From the assembly files, we can see that the symbol 'g_Var' in both the source files are defined as common symbols. Now to see both the common symbols share the same data area, we shall probe the map file generated by linker.

On providing the following on the command prompt, we get the map file file.map.

$gcc file01.c file02.c -Wl,-Map,file.map

In file.map, we can see the following:

Allocating common symbols
Common symbol       size              file

g_Var               0x4               /tmp/cciZ1YQm.o

The above code snip from file.map shows that the symbols in file01.c and file02.c shares the same data area.

What if the symbol 'g_Var' is declared globally in files file01.c and file02.c but with of different sizes as shown below?

file01.c
--------
int g_Var;

int main()
{
    g_Var = 4;

    vFunction ();

    if (8 == g_Var)
    {
        printf ("Passed\n");
    }
    else
    {
        printf ("Failed\n");
    }

    return 0;
}

file02.c
--------
long long g_Var;

void vFunction()
{
    g_Var = 8;
}

This is same as that of the previous case. The point we should make a note is, the common data area defined for the symbol would be as that of the bigger data type.

Let us probe the assembly files and map file for better understanding of this case.

On providing the following on the command prompt, we get the assembly files file01.s and file02.s.

$gcc file01.c file02.c -S

In file01.s, we can see the following:

.file   "file01.c"
        .comm   g_Var,4,4

In file02.s, we can see the following:

.file   "file02.c"
 .comm g_Var,8,8

The common symbol 'g_Var' is defined of size '4' in file01.s while the same is defined of size '8'. Now to see both the symbols share the same data area with size '8' (bigger of the two - '4' and '8'), we shall probe the map file generated by linker.

On providing the following on the command prompt, we get the map file file.map.

$gcc file01.c file02.c -Wl,-Map,file.map

In file.map, we can see the following:

Allocating common symbols
Common symbol       size              file

g_Var               0x8               /tmp/cczBMPJt.o

The above code snip from file.map shows that the symbols in file01.c and file02.c shares the same data area. And the bigger size '8' is allocated for the same.

An exercise for you: With the above discussion, can you say what would be the result on executing the following programs?

file01.c
--------
long long g_Var;

int main()
{
    g_Var = 0xffffffffffffffffLL;

    printf ("g_var before calling vFunction = %llx\n", g_Var);

    vFunction ();

    printf ("g_var after calling vFunction = %llx\n", g_Var);

    return 0;
}

file02.c
--------
int g_Var;

void vFunction()
{
    g_Var = 0x0;
}

What if the symbol 'g_Var' is defined globally in file01.c and declared globally in file02.c as shown below?

file01.c
--------
int g_Var = 4;

int main()
{
    vFunction ();

    if (8 == g_Var)
    {
        printf ("Passed\n");
    }
    else
    {
        printf ("Failed\n");
    }

    return 0;
}

file02.c
--------
int g_Var;

void vFunction()
{
    g_Var = 8;
}

In such cases, the 'g_Var' of file01.c would be defined as a global symbol while the 'g_Var' of file02.c would be defined as a common symbol which refers to the data area defined by the global symbol 'g_Var' of file01.c.

Let us probe the assembly files and map file for better understanding of this case.

On providing the following on the command prompt, we get the assembly files file01.s and file02.s.

$gcc file01.c file02.c -S

In file01.s, we can see the following:

.file   "file01.c"
.globl g_Var
 .data
 .align 4
 .type g_Var, @object
 .size g_Var, 4
g_Var:
 .long 4
 .section .rodata

In file02.s, we can see the following:

.file   "file02.c"
 .comm g_Var,4,4

In file01.s 'g_Var' is defined as global symbol and in file02.s 'g_Var' is defined as common symbol. Now to see that 'g_Var' common symbol would refer to the data area that is defined by 'g_Var' global symbol of file_01.c, we shall probe the map file generated by linker.

On providing the following on the command prompt, we get the map file file.map.

$gcc file01.c file02.c -Wl,-Map,file.map

In file.map, we can see the following:

.data          0x000000000804a014        0x4 /tmp/ccQO9fBj.o
                0x000000000804a014                g_Var

In the map file, we can see that there is no common symbol. I.e. Symbol 'g_Var' in both files file01.c and file02.c refers to the same data area.

And finally, what if the same symbol 'g_Var' is defined in both file01.c and file02.c globally?

The compiler would define the symbol 'g_Var' as global symbol in both the files file01.s and file02.s. And the linker would shout for multiple definition of symbol 'g_Var'. Probe this case on your own as we did for other cases above.

Thursday, December 9, 2010

Patch files

During our work on linux environment, we might often come across the situation of updating the source files we work on using patch files. That is, the need for updating the source files for changes.

The patch files have the differences between the source (say X) that is to be updated and the updated version of that source (X).

So how to create a patch file? or how to patch up a source with the provided patch file? These are very well explained under Tools and Techniques.

Monday, December 6, 2010

Installing windows - Could not load CD/DVD drive

"Hey, I have a problem with installing windows 7 on my laptop. Could you please help me out." said my colleague. He got the laptop from US. It was gifted to him by his elder brother who was there for an on-site assignment. The laptop is a make of HP (Pavilion dv4-2173nr) and had windows 7 installed. Wishing to have a linux distribution on the laptop he lost his windows 7 installation.

Now on trying to install the windows 7 he encounters the following error:

Windows Install could not load the CD/DVD drive that contains the installation media.  Please provide the necessary drive or controller device drivers provided by your manufacturer.

The error message doesn't help at all. The actual problem is that the windows 7 installation media doesn't have a driver for the hard disk available with the laptop.

Searched and downloaded the driver for the hard disk (of Pavilion dv4-2173nr) from the HP site.

Loaded the driver into USB memory stick and used it during the installation. The installation was successful.

Thursday, November 11, 2010

Data manipulation across spreadsheets

There may come situations, you require to get the values from two or more spreadsheets and use those values in a separate spreadsheet.

This can be easily done in MS Excel. Assume that there are three spreadsheets A.xls, B.xls, and C.xls. Each spreadsheet has their own sheet as A_sheet1, B_sheet1 and C_sheet1 respectively.

Now we are to create new spreadsheet ABC.xls that would use the values from cell 'C16' of sheets A_sheet1, B_sheet1 and C_sheet1. To access the cell 'C16' from each spreadsheet, use the following formula in the spreadsheet ABC.xls.

  1. To access the values from cell 'C16' of sheet A_sheet1 of A.xls:
    • ='D:\[A.xls]A_sheet1'!C16
  2. To access the values from cell 'C16' of sheet B_sheet1 of B.xls:
    • ='D:\[B.xls]B_sheet1'!C16
  3. To access the values from cell 'C16' of sheet C_sheet1 of C.xls:
    • ='D:\[C.xls]C_sheet1'!C16

Sunday, October 24, 2010

DivX Player Compatible AVI video files

Recently I bought a DivX player provided with USB connection. I tried to play few .avi files from the memory stick. The DivX player isn't playing those .avi files saying invalid format.

Searched for a DivX converter from net. The platform is Ubuntu. Got a DivX converter and converted the .avi files to DivX Player Compatible AVI video format files. Now my DivX player is able to play those files.

Download: DivX Converter

Monday, September 27, 2010

Internationalization of glibc

Internationalization of a software refers to the process of making that software to adapt the user's favorite conventions. So internationalization of glibc means programming glibc to adapt the user's favorite conventions.

In glibc, internationalization is done using locales. Locales are collection of conventions. Locales should be specified via environment variables. There are standard locales such as 'C' and 'POSIX' that are supported by all operating systems (OS).

The glibc features that should be internationalized are categorized. Each category can be specified separately with a locale as the user wishes. The environment variable corresponding to each category should be defined for the same. The list of such environment variables are as follows:
  1. LC_COLLATE
  2. LC_CTYPE
  3. LC_MONETRY
  4. LC_NUMERIC
  5. LC_TIME
  6. LC_MESSAGES


If the user prefers to specify a single locale for all categories, then the user can use the environment variable 'LC_ALL'.

Failing to define locale may end up with error on running the glibc test-suites via 'make check'.