In the previous articles, I introduced the android source code download method under UbuntuLinux, the Eclipse development environment for android under Ubuntu11.10, and some problems encountered during the configuration process, this article will continue to introduce the android source code 4.0.3 compiler under Ubuntu11.10... in previous articles, I introduced some problems encountered in the configuration process, including "how to download the android source code for Ubuntu Linux", "how to configure the Eclipse development environment for android under Ubuntu11.10, this article continues to introduce how to compile android 4.0.3 in Ubuntu11.10.
1. initialize the compiling environment
Software Requirements:
Python2.5-2.7, which can be downloaded at http://www.python.org/download/( with Ubuntu11.10 ).
JDK6: compile Gingerbread or update version; JDK5: compile Froyo or earlier versions. You can download the SDK at http://java.sun.com/javase/downloads/or through the ubuntusoftware center.
You can download Git1.7 or the latest version at http://git-scm.com/download, or directly download sudo apt-get install git under the latest version.
Install JDK
JDK installation in Ubuntu is relatively simple. you can search for the installation in the software center or install it in the following ways:
Install Java 6:
Configure USB access permissions
In GNU/Linux systems (especially in Ubuntu systems), by default, normal users cannot directly access USB devices. Therefore, some system configurations are required.
Create a new configuration file/etc/udev/rules. d/51-android.rules as a super user and copy the following content to the new configuration file:
2. configure ccache
Ccache (abbreviation of "compiler cache") is a compiler cache. this tool caches the compiled information and uses the cached information in specific parts of the compilation, such as header files, this saves the time required to parse the information using cpp. If you compile the file in listing 2 and assume that foobar. h contains references to other header files, ccache replaces the include declaration with the cpp-parsed version of that file. Ccache only copies the final text to the file so that it can be compiled immediately, instead of actually reading, understanding, and interpreting its content.
This step is optional. I didn't configure ccache during compilation, and it took Nima at least six hours for the final compilation. although I haven't tried to configure the compilation speed after ccache, we recommend that you configure it to save compilation time. The configuration method is as follows:
Open. bashrc in the user directory, add the following statement to the end of the file, and save and exit:
1 export USE_CCACHE = 1
By default, the cache is saved in ~ /. In the ccache Directory, if the main directory is in NFS or another non-local file system, add the following statement to. bashrc, save it, and exit:
1 export CCACHE_DIR =
Set
1 Change to the location of the cache directory.
The recommended cache directory is 50-100 GB. run the following command on the command line:
1 prebuilt/linux-x86/ccache-M 50G
This setting will be saved to CCACHE_DIR, and this command is long-term and will not expire due to system restart.
3. use a lower version of gcc and g ++
The gcc and g ++ versions of Ubuntu11.10 are 4.6. some errors may occur when android is compiled using this version, such:
Although this method can solve this problem, it will also lead to new problems and continue to be modified, which is very troublesome and will damage the native status of the android source code. However, if gcc and g ++ of version 4.4 are used, the following error will not occur:
Through the gcc-v command, we can find that the gcc Library is under the/usr/lib/gcc/i686-linux-gnu directory, which contains the gcc library of various versions supported by the current system. There is no 4.4 Directory in this directory before gcc 4.4 is installed. after gcc 4.4 is installed, there will be an additional 4.4 Directory in this directory, and there will be various library files under this 4.4 Directory.
The best way to install gcc 4.4 in ubuntu 32bit system is to use only the following two commands without other commands. otherwise, errors may occur during compilation.
Check the gcc and g ++ versions:
Gcc-v
G ++-v
Gcc version 4.4.6 is displayed, indicating that gcc 4.4 is successfully installed.
4. Compile the android source code.
Go to the source code directory. The directory is/home/tasiller/android/source. Use the envsetup. sh script to initialize the installation environment. The following code is available:
1 $ source build/envsetup. sh
Or
1 $. build/envsetup. sh
Note: There is a space behind it.
Then, select the target to be compiled:
1 $ lunch full-eng
Then the source code is compiled using the make command:
1 $ make-j4
Here-j4 indicates that four threads are used for compilation, and 4 indicates the number of threads. you can set it according to your own machine (for example, if the machine is a single-CPU dual-core processor, it can be set to-j2 or-j4, that is, this number is twice the total number of CPU cores or the total number of kernels .)
Then there is a long wait...
After compilation, you can see the compiled ramdisk. img, system. img, and userdata. img in the out/target/product/generic/directory of the source code directory.
If not stated, the articles on this site are original articles of Taskiller
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.