Android 2.3.5 source code compilation process in Ubuntu 14.04 LTS, 14.042.3.5

Source: Internet
Author: User
Tags gnupg srec

Android 2.3.5 source code compilation process in Ubuntu 14.04 LTS, 14.042.3.5
During the compilation of android 2.3.5 source code in Ubuntu 14.04 LTS, many problems may occur in the early compilation of android source code in the 64-bit Ubuntu system, because after the 64-bit system is installed, many 32-bit compatibility packages are not installed, and many 32-bit Development kits were used in early android. It is often difficult for new users to figure out the root cause of the problem. In addition, the compilation of Android source code depends on many additional third-party development packages. Therefore, the compilation process may fail due to the lack of these packages. Another problem is that in the new Ubuntu system, due to the upgrade of gcc and g ++ compilers, early code is interrupted due to errors in the new compiler. For example, after the 64-bit Ubuntu 14.04LTS system is installed, both gcc and g ++ versions are 4.8, and many documents on the Internet say that the android source code for compiling 2.3 needs to be downgraded to 4.4. I think this is because some code in earlier versions seems to be wrong in later compilers, so there are many places to modify Android. mk file, add the-fpermissive compilation option. permissive stands for tolerance in English, and probably refers to the meaning of some Syntax structures in the early stages of tolerance. So first install some required dependency packages, then, you can connect gcc and g ++ with soft links to the gcc and g ++ compilers of version 4.4 to reduce many compilation failures. Here I will list some dependent packages, but each person may have different situations, so there must be something missing. You should be able to solve the problem by searching online:sudo apt-get install git-core gnupg flex bison gperf build-essential \

      zip curl libc6-dev libncurses5-dev:i386 x11proto-core-dev \

      libx11-dev:i386 libreadline6-dev:i386 libgl1-mesa-glx:i386 \

      libgl1-mesa-dev g++-multilib mingw32 tofrodos \

      python-markdown libxml2-utils xsltproc zlib1g-dev:i386

 

Sudo apt-get install git-core gnupg flex bison gperf libsdl1.2-dev libesd0-dev libwxgtk2.6-dev squashfs-tools build-essential zip curl libncurses5-dev zlib1g-dev pngcrush schedtool libxml2 libxml2-utils extends tproc

 

Download the Android source code:

There are two methods:

1. Directly download the package that someone else has downloaded

Baidu Network Disk shared by others: http://pan.baidu.com/share/link? Container id = 7577 & uk = 4246628909, 2.3.5, you must first install 7z to decompress the package, and then obtain a tar of about 2 GB. An error occurs when extracting the file directly, the error message indicates that hard link cannot be created. Run the following command:

Sudo tar-xf Android_Kernel.tar -- exclude */. git-C/opt/android/sources

2. Use repo to obtain

Reference: http://jileniao.net/post-156.html

Refer to the http://blog.csdn.net/sunweizhong1024/article/details/8055372 for repo usage

Because the repo sync will be interrupted by the network, you can use the following script to automatically re-run it.

 

#! /Bin/bash

Command = "repo sync"

$ Command result = $? Echo "result =" $ result until [$ result-eq 0] do echo "retry" $ command result = $? Done

      

Compile: start... go to the source code path and run make to start the compilation process. Some errors during the compilation process and solutions are listed below. error dalvik/vm/native/dalvik_system_Zygote.c: 191: 19: error: storage size of 'rlim' isn' t known
Struct rlimit rlim;

Solution: add the header file # include <sys/resource. h> to the following file:
Dalvik/vm/native/dalvik_system_Zygote.cpp 2. make: *** [out/host/linux-x86/obj/EXECUTABLES/mksnapshot_intermediates/src/accessors. o] Error 1 check information online, online is said because GCC and G ++ version is too high, should use gcc-4.4 and g ++-4.4, run the following command to view my own gcc -- version (result 4.8) g ++ -- version (result 4.8). The solution is simple, install gcc 4.4 and g ++ 4.4 sudo apt-get install gcc-4.4 g ++-4.4g ++-4.4-multilib after installation there will be gcc-4.4 and g + under/usr/bin +-4.4, delete the original symbolic links of gcc and g ++ and re-establish them to the version we installed: sudo rm-f/usr/bin/gcc sudo rm-f/usr/bin/g + + sudo ln-s/usr/bin/gcc-4.4/usr/bin/gcc sudo ln -s/usr/bin/g ++-4.4/usr/bin/g ++ 3. external/srec/tools/thirdparty/OpenFst/fst/lib/cache. h: 136: 11: note: use 'this-> setstate' instead
Make: *** [out/host/linux-x86/obj/EXECUTABLES/grxmlcompile_intermediates/grxmlcompile. o] Error 1 solution: cd external/srec wget "https://github.com/CyanogenMod/android_external_srec/commit/4d7ae7b79eda47e489669fbbe1f91ec501d42fb2.diff"
Patch-p1 <4d7ae7b79eda47e489669fbbe1f91ec501d42fb2. diff
Rm-f 4d7ae7b79eda47e489669fbbe1f91ec501d42fb2. diff

4. in file encoded ded from system/extras/ext4_utils/output_file.c: 30:/usr/include/zlib. h: 34: fatal error: zconf. h: There is no file or directory compilation terminated.

Solution: The reason is that the zlib1g-dev has a head file modified the path, and zconf. h put to/usr/include/x86_64-linux-gnu/, So copy it to/usr/include /.

 

5. make: *** [out/target/product/generic/obj/STATIC_LIBRARIES/libwebcore_intermediates/WebCore/HTMLNames. h] Error 2
Solution: install sudo apt-get install libswitch-perl

 

Verify

 

After compilation is complete, try my compilation result:

The simulator emulator generated after compilation is in the out/host/linux-x86/bin of the source code, and the generated system is in the out/target/product/generic Directory, the main is system. img, userdata. img and ramdisk. img. There are two ways to run emulator

First, set the ANDROD_PRODUCT_OUT environment variable to the generated system storage directory, for example, out/target/product/generic on my machine:

Export ANDROD_PRODUCT_OUT = out/target/product/generic ~ /. Bashrc)

Then go to the source code directory and run emulator.

In this case, the system image files used are from the system. img, userdata. img and ramdisk. imgfile, and its kernel File uses the prebuilt/android-arm/kernel-qemu file in the source code directory.

Second: Use the complete emulator command parameters to start the simulator.

Emulator-kernel/Develop/sources/android/2.3.5/Prebuilt/android-arm/kernel-qemu-sysdir/Develop/sources/android/2.3.5/Out/target/product/generic-system. img-data userdata. img-ramdisk. img

The font bold part should be modified according to the source code path. Like the intuitive representation of command parameters,-the kernel is followed by the specified kernel File. Because I didn't compile my own kernel, I directly used the pre-compiled kernel provided by the source code, -The sysdir parameter is followed by the storage path of the system's image file. If no absolute path is used for the file specified by parameters such as-system,-data, and-ramdisk, use the path specified by-sysdir.

 

The following error occurs when I run the compiled emulator:

SDL init failure, reason is: No available video device

I just installed the latest Android SDK some time ago with emulator in it. I will try it to see if it can be successful:

1. Open the Console port and enter the directory where emulator is placed

Cd/opt/android/sdk/tools

2. Then run the emulator command.

Emulator-kernel/develop/sources/android/2.3.5/prebuilt/android-arm/kernel-qemu-sysdir/develop/sources/android/2.3.5/out/target/product/ generic

Successful!

If I run:

Emulator-kernel/develop/sources/android/2.3.5/prebuilt/android-arm/kernel-qemu-sysdir/develop/sources/android/2.3.5/out/target/product/ generic-system. img-data userdata. img-ramdisk. img

The following error occurs:

Qemu: cocould not load initrd 'ramdisk. img'

Some netizens on the Internet say that you can use the full path to specify the ramdisk path. After an experiment, this is the case. -Ramdisk/develop/sources/android/2.3.5/out/target/product/generic/ramdisk. img, there are also some posts saying that the write permission is required for the out/target/product/generic path, but I do not belong to this situation. If it is compiled by another user, this problem may occur, write the solution for future reference:

Chmod 777 out/target/product/generic

 

Since the Android SDK emulator can be used, but the emulator compiled by me cannot be used, it indicates that it is a problem with emulator. Suddenly I think it will be a problem of 64-bit and 32-bit. The emulator I compiled is the 2.3.5 source code. At that time, it may be a 32-bit development kit. Check the information on the Internet. As I guess, the solution is simple to install a 32-bit development kit.

I first installed the X11 32-bit development kit:

Sudo apt-get install libX11-dev: i386 (note that i386 after the colon indicates that the 32-bit version is installed)

Run, the problem is still the same, there must be something not fully installed, find the information again, but also install the SDL 32-bit package:

    sudo apt-get install libsdl1.2debian:i386

The post also says:

    sudo apt-get install ia32-libs-sdl(I have not tried this)

 

Alsoexport DISPLAY=:0This may be useful to some people.

Reference: http://stackoverflow.com/questions/4841908/sdl-init-failure-reason-is-no-available-video-device/10128566

 

 

A good reference link:

Http://www.cnblogs.com/kobe8/p/3998379.html

Http://www.cnblogs.com/webapplee/p/3946506.html

Http://blog.csdn.net/jiangwei0910410003/article/details/37988637

Http://www.omitol.com/archives/65.html

Http://www.linuxidc.com/Linux/2012-09/70052p2.htm

 

Contact Us

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.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.