Saturday, September 18, 2010

Building Chrome on 64 bit Ubuntu 10.04

Unhappy with the prospect of turning where I live into a computer junkyard but excited by the Chrome debugging idea, I bought yet another laptop. I ran into a bit of trouble installing Ubuntu on this new HP machine because it came from the factory with four primary partitions already allocated on the hard drive. On a hard disk, you can only create a max of four primary partitions, or alternatively three primary and one extended partition (extented partitions let you create multiple subpartitions within them).

Of the HP's four different partitions, two of them were for Windows 7, one for HP recovery and one for HP diagnostic tools. To install Ubuntu, I copied the HP diagnostic tools to the C: drive, then deleted that partition. Then I shrank the Windows partition to about half of its size to open up space for Ubuntu. How do you resize a partition? There are many tools for doing this. In my case I booted Ubuntu from the live CD and ran the gparted tool (i.e. "sudo gparted &" from a Linux terminal window).

I then created an extended partition - you can convert one primary partition to an extended partition - and within the extended partition I recreated a small partition for the HP tools, a 6G partition for Linux swap space, and all the remaining space went to a large partition for Ubuntu. I then installed Ubuntu on one of these subpartitions and then I formatted the new HP tools partition as a FAT32 file system and copied the HP Diagnostics back to it. The diagnostics require FAT32 and won't run on NTFS which is what Windows normally uses. FAT stands for File Allocation Table and is just a type of file system.

Compiling Google Chrome on this system was a piece of cake compared to the trouble I was having building it on an older system with 2 Gig of RAM (on that system I was only able to successfully build the Release version, and could never get the Debug version to link, even after adding lots of swap and using the 'gold' linker). I say older system but even my two year old transreflective Toshiba that I have for working from outdoors has 2G. It seems crazy to have to pay $3,500 just to get upto 3G RAM on that machine.

To build Chrome, I followed the directions on the wiki. To summarize, here's what it involves:
  • Get the prerequisite tools installed by running the install build deps script. The script asks you a series of questions. I said No to installing debug symbols for system libraries, and Yes for all the other questions. I found that the script installed everything that I needed.
  • Download the source tarball. I ran gunzip on it then: sudo tar -xf chrom*.tar (note: I found I had to untar it with root permissions due to the ownership settings of the files within the archive.)
  • After untarring I moved the chromium directory under my home directory, and changed the ownership of all the files:
    sudo mv chromium $HOME
     cd $HOME
     sudo chown -R computergal chromium
     sudo chgrp -R computergal chromium
  • Next you have to install Google's "depot_tools":
    mkdir $HOME/depot_tools
     cd $HOME/depot_tools
     svn co
  • Then use the depot tool to update the source tree:
    cd $HOME/chromium/src
      gclient sync --force 
  • It takes a while to update, but then you are ready to build:
    cd $HOME/chromium/src 
      make -j3 chrome
    (the -j3 parameter is optional - it just makes the build a little faster by starting up multiple compilation processes.)

I'm not sure how long it took to build as I left the computer unattended. But when I returned about 4 hours later very late last night, it had successfully compiled and linked:
Screenshot of Successful Google Chrome Build on 64 bit Ubuntu
I launched the new executable, and Chrome came up!
> $HOME/chromium/src/out/Debug/chrome &

Now that I can compile Google Chrome, I need to go in and look at the browser rendering code and add some logging to trace its behavior. But before that, I'm going to go down by the beach for a break.

Post a Comment

Note: Only a member of this blog may post a comment.