2009年12月3日 星期四

How to Build Chrome OS

Here, I will show how to build Google Chrome OS in a simple way.

Enviroment:
  1. Ubuntu 8.04 or Ubuntu 9.10, but it was fine to use Ubuntu 9.04 to build (it works fine with me).
  2. An account which can use "sudo" command.
  3. Internet environment, since we get all the source on the cloud.
Notice, there should have no error for the following steps.  If you have the problem, you should try to resolve it rather than skip it.

(1) Install packages by following command.
sudo apt-get install subversion pkg-config python perl g++ g++-multilib bison flex gperf libnss3-dev libgtk2.0-dev libnspr4-0d libasound2-dev libnspr4-dev msttcorefonts libgconf2-dev libcairo2-dev libdbus-1-dev wdiff lighttpd php5-cgi sun-java6-fonts git-core;
  For the builder in Taiwan, there will be a problem while installing msttcorefonts.  It is a problem of the server, not your problem.  Try the method below to solve the problem.
$ host ncu.dl.sourceforge.net;
ncu.dl.sourceforge.net has address 140.115.17.45
$host nchc.dl.sourceforge.net
nchc.dl.sourceforge.net has address 211.79.60.17
nchc.dl.sourceforge.net has IPv6 address 2001:e10:ffff:1f02::17
$echo "211.79.60.17 ncu.dl.sourceforge.net" >> /etc/hosts;
$sudo apt-get install msttcorefonts;
  For further information, please refer to this website(chinese).

(2) Get gclinet(depot_tools)

  Get the depot_tools by download it and unzip it in your home folder.  Here, we provide the easiest way to get the tool.  For further information, please refer to the website(english).

  Next, modify the file in /home/<Your Account>/.bashrc by following command.

sudo gedit ~/.bashrc;
  Add the following line in the end of the file, and save it

export PATH=${PATH}:/home/<your account>/<path to depot_tools>/depot_tools

  Remeber to restart the terminal window to reload the bash file.  You should try typing "gclient" first to try if it is setting properly.

(3) Get the source of Google Chrome OS

  Use the following command to get the newest Google Ghrome OS's source code.
mkdir chromiumos;
cd chromiumos;
gclient config http://src.chromium.org/git/chromiumos.git;
gclient sync;
  This will take a while.

(4) Build the Google Chrome OS

  Use the following command to build Google Chrome OS. All the command has been written in the directory chromiumos/chromiumos.git/src/script . You switch to there first.
./make_local_repo.sh;
./make_chroot.sh;
  If you failed on the first command, before re-build it, you should remove a folder by following command.
sudo rm -rf ~/chromiumos/chromiumos.git/repo/;
  If you failed on the second command, you should use the following command instead.
./make_chroot.sh --replace;

(5) Download Chrome Browser

  This step is simple, just goto this link and download the file like chromium-chromiumos-rxxxxx.zip, save it in ~/chromiumos/chromiumos.git/src/build/x86/local_assets, and than rename it into chromium-chromiumos.zip.

(6) Make the image

  Use the folling commands to make the image of Google Chrome OS
./enter_chroot.sh;
( cd ../platform/pam_google && ./enable_localaccount.sh USERNAME );
./set_shared_user_password.sh;
./build_platform_packages.sh;
./build_kernel.sh;
./build_image.sh;
exit;
  The image will be saved in ~/chromiumos/src/build/images/ .

(7) Use the image
  Here, we just simply put the image into a usb drive by following command.
./image_to_usb.sh --from=~/chromiumos/src/build/images/SUBDIR --to=/dev/USBKEYDEV;
  You can find the value of your usb drive by "sudo fdisk -l;".

  At last, your Chrome OS is finally done.
 
  To test it, you can plug in the usb drive to any computer, boot it by usb. than you will see the Chrome OS login screen.  The user name and password is what you type before, not the google account.

2009年9月23日 星期三

wxwidgets

This is an article that tells you how to install wxWidgets with DevCpp and MSYS.

wxWidgets is an cross-platform GUI library.  You may write an application almost without changing the code.  All you need is to re-compile the code on the OS you want.

DevCpp is an application that helps you writing in C and Cpp.  I always write C or Cpp program with it on Windows.

MSYS is an application that provide Windows user with Unix-like environment.

I'm going to show you how to use these to build an library and open an project under Windows.

1. Download the wxWidgets Library, DevCpp, and MSYS.

Any version of the wxWidgets Library is OK, but I prefer wxAll, which works for all OS.

2. Install DevCpp

Just use the default option.

3. Install MSYS

At the end of the installation, it will appear a console window.  This is asking you do you have any MinGW Compiler installed.  Since we install DevCpp, which automatically bundle the MinGW compilers.  For this question, the answer is YES.

Then, it will show another question in the console window.  The question is asking you where do you install the compilers.  You should type in "C:\Dev-Cpp\".

After you press enter, there still another question, which asking you if MSYS can change a program name to another.  I just follow the default option "YES", and I can't see what the difference after rename the file.

4. Extract wxWidgets

Just Extract, Using 7-zip or other similar tools.  Extract to "C:\" or other place you know. I install it in "I:\wxWidgets", which is an portable drive so that I can write code any where.

5. Setting Up Gloable Variable

Right click at "My Computer" and select Properties.  Click on the advanced tab then the 'environment variables' button.  In system variables, look for a variable called path and double click on it.  Add the following to the beginning of the value: "C:\Dev-Cpp\bin;c:\msys\1.0\bin;".

6. Build the Library

Note: My wxWidgets Library is Extract into "I:\wxWidgets".  You should know where your wxWidgets just Extract.

Open the MSYS from Desktop, following the following command to build the library.  Only the text in this style should be typed in to the window.
cd i:  => To change directory
cd wxWidgets => change directory to I:\wxWidgets
cd wxWidgets-2.9.0 => change directory to I:\wxWidgets\wxWidgets-2.9.0
mkdir mswDebug => make a directory named "mswDebug"
cd mswDebug => change directory to I:\wxWidgets\wxWidgets-2.9.0\mswDebug
../configure --enable-debug => to setup library, this may takes a while
make => to build the library, this may takes a while, too
make install => to install the library to the MSYS, this may also takes a while
Follow the step above should have no error.  The last three command will take some time, you MUST WAIT until the screen stop and you can enter command.

6. Setting Up DevCpp Project

Here, I WILL NOT tell you how to write wxWidgets program.  Here, I only tell you what you should set before compiling the project.

Goto the "Project/Project Options" to open the option dialog.

In "General" tab, the "Type" of the application is "Win32 GUI".

Type "wx-config --cppflags" in MSYS, copy the text appear on the screen.  NOT ALL THE TEXT SHOULD YOU COPY. Just copy the text that after -D.  For Example, my screen pop up as "-I/usr/local/lib/wx/include/msw-unicode-debug-2.9 -I/usr/local/include/wx-2.9 -D_LARGEFILE_SOURCE=unknown -D__WXDEBUG__ -DWXUSINGDLL -D__WXMSW__", you just copy the text that is marked as this.  And then paste them into the "C++ compiler" in the "Parameters" tab.

Type "wx-config --libs" in MSYS.

2009年9月17日 星期四