基于ubuntu10.04和ubuntu14.04搭建MTK6577+Android4.04开发环境的问题与解决

基于ubuntu10.04和ubuntu14.04搭建MTK6577+Android4.04开发环境的问题与解决

 

 

1.     需要的软硬件环境

 

(1)    操作系统

推荐用ubuntu10.04。

 

(2)    内存和硬盘空间

内存要求是4GB或以上,我试过用同样的ubuntu10.04,分别在台式机和PC机上编译(内存都为4GB),台式机编译可以通过,但笔记本上就提示内存过小,无法编译,原因目前不清楚。后来笔记本我升级到了6GB,接下来记录环境搭建和编译遇到的问题及解决。

 

2.     Ubuntu10.04搭建编译环境时遇到的问题

编译出错:

基于ubuntu10.04和ubuntu14.04搭建MTK6577+Android4.04开发环境的问题与解决_第1张图片

图1

 

根据hsimobile77_ics2_preloader.log_error下面的出错提示信息:

wine:'/home/kandi' is not owned by you, refusing to create a configuration directorythere

===BUILD FAIL.tools/pbp/PBP.exe return fail===

可知是因为没有权限创建目录引起的,我改为用root编译就可以了,但整个全部编译需要用了5个半小时的时间。

 

3.     Ubuntu14.04搭建编译环境时遇到的问题

 

3.1  安装软件和编译工具链(compilation Tool Chain)

 

(1)    更新APT信息

apt-get update

 

(2)    安装包

基于ubuntu10.04和ubuntu14.04搭建MTK6577+Android4.04开发环境的问题与解决_第2张图片

图2

 

安装的时间建议单独安装,可以清楚知道哪些包是否已经安装,在安装flex的时候,弹出下面的信息:

Reading packagelists... Done

Buildingdependency tree      

Reading stateinformation... Done

Package flex isnot available, but is referred to by another package.

This may mean thatthe package is missing, has been obsoleted, or

is only availablefrom another source

解决的办法,是选择下图中main

基于ubuntu10.04和ubuntu14.04搭建MTK6577+Android4.04开发环境的问题与解决_第3张图片

图3

在安装ia32-libs的时候,提示这个包较老,被淘汰了,需要用其他包来代替:

Reading packagelists... Done

Buildingdependency tree      

Reading stateinformation... Done

Package ia32-libsis not available, but is referred to by another package.

This may mean thatthe package is missing, has been obsoleted, or

is only availablefrom another source

However thefollowing packages replace it:

  lib32z1 lib32ncurses5 lib32bz2-1.0

 

安装lib32readline5-dev时也需要一样的提示:

Reading package lists... Done

Building dependency tree      

Reading state information... Done

Package lib32readline5-dev is not available, but isreferred to by another package.

This may mean that the package is missing, has beenobsoleted, or

is only available from another source

However the following packages replace it:

  lib32readline-gplv2-dev

根据系统推荐的包来安装。

 

安装wine包时,弹出图形界面,如下图:

基于ubuntu10.04和ubuntu14.04搭建MTK6577+Android4.04开发环境的问题与解决_第4张图片

图4

刚弹出来时OK时黑色的,我记得刚开始自己遇到这样的情况下无法选择OK,后来不经意,选择了向右的键,就可以选择了,在此记录下来,仅仅是作为备忘。

 

(3)    安装arm-linux-androideabi-4.4.x

解压MTK6577源代码包,文件在下面目录下:

prebuilt\linux-x86\toolchain\arm-linux-androideabi-4.4.x,安装的命令如下:


图5

注意这里的arm和-有一个空格的。

 

(4)    安装JDK1.6

文件为jdk-6u23-linux-x64.bin,先修改属性然后安装,命令如下:

chmod a+xjdk-6u23-linux-x64.bin

./ jdk-6u23-linux-x64.bin

(5)     

 

3.2  配置编译文件(configure build profile)

解压后的源代码文件夹根目录下有mblden.sh,参考《ALPS_Build_Environment_on_Ubuntu_10.04_64-bit_Installation_SOP_4.0》文档的Configure Build Profile部分,确保源代码根目录下的mblden.sh下的内容如下:

JAVA_HOME=/opt/jdk1.6.0_23

export JAVA_HOME

 

# OverwriteANDROID_JAVA_HOME environment variable setting if already exists

ANDROID_JAVA_HOME=/opt/jdk1.6.0_23

exportANDROID_JAVA_HOME

 

# Overwrite PATHenvironment setting for JDK & arm-eabi if already exists

PATH=/opt/jdk1.6.0_23/bin:$PWD/prebuilt/linux-x86/toolchain/arm-linux-androideabi-4.4.x/bin:$PATH

export PATH

 

这里重点要注意的是JDK和arm-linux-androideabi的版本一定要和安装在系统上的版本一致,而且是所要求的版本。在解压了源代码之后这里是jdk1.6.0.26,我们改为jdk1.6.0.23

 

然后进入源代码目录下,执行下面的命令:

(1)  sourcembldenv.sh

此文件设置正确的环境变量。可以直接用export,或者修改脚本。

修改arm-eabi-gcc和java的路径. 即修改mbldenv.sh里面PATH, JAVA_HOME等环境变量,不能使用相对路径。

 

(2)  ./mknew

情况所有的老文件、库和logo文件等,也会创建需要的目录、删除所有的临时文件和刷新日记文件

 

 

在编译源代码之前,先检查编译环境,编译的时候遇到的问题如下:

 

3.1  编译遇到的问题和处理步骤

 

3.1.1       Gcc版本过高问题

(1)  错误信息

 

提示信息如下:

[gcc]: unknown(64-bit) [FAIL]

(2)  解决办法

 

进入命令:/usr/bin下用 ls -l gcc*命令查看gcc的版本最重要的信息如下:

gcc -> gcc-4.8

表示目前gcc链接版本是gcc-4.8,高于推荐的版本,导致无法编译。那我们只能降低gcc版本为4.4.3

apt-get installgcc-4.4

apt-get installg++-4.4

接着把gcc链接的版本有4.8改为4.4

 

sudo mv gccgcc.bak   ------------备份

sudo ln -s gcc-4.4gcc   ------------重新链接

然后再用ls -l gcc*命令查看gcc的版本最重要的信息如下:

gcc -> gcc-4.4

然后重新编译就不存在此问题了,环境检查输出信息如下:

Build EnvironmentRequirement

=============================================================

* *********Suggested OS and Tool Chain to install *********

*

*       OS                         : Linux distributionUbuntu 10.04

*       Memory Size                : 2G or above

*       make                       : GNU Make 3.81 or above

*       perl                       : Version 5.10.X

*       python                     : Version 2.6.X

*       arm-linux-androideabi-gcc  : Version 4.4.X

*       gcc                        : Version 4.4.3

*       jdk                        : Version 1.6.X

*       bison                      : Version 2.4.X

*       flex                       : Version 2.5.X

*       gperf                      : Version 3.0.X

*       mingw                      : Installed

*       unix2dos/tofrodos          : Installed

* **********************************************************

=============================================================

 

 

Build EnvironmentCheck Result Report

*************************************************************

 

[OS]: Ubuntu 14.04(64-bit) [WARNING]

your ubuntu osversion is higher than recommendation

 

[Physical MemorySize] : 6003508 K-Bytes [OK]

[make]: 3.81(64-bit) [OK]

[perl]: 5.18.2(64-bit) [WARNING]

your perl versionis higher than recommendation

 

[python]: 2.7.6(64-bit) [WARNING]

your pythonversion is higher than recommendation

 

[arm-linux-androideabi-gcc]:4.4.3 (32-bit) [OK]

[gcc]: 4.4.7(64-bit) [WARNING]

your gcc versionis higher than recommendation

 

[jdk]: 1.6.0_23(64-bit) [OK]

[bison]: 3.0.2(64-bit) [WARNING]

your bison versionis higher than recommendation

 

[flex]: 2.5.35(64-bit) [OK]

[gperf]: 3.0.4(64-bit) [OK]

[mingw]: Installed[OK]

[unix2dos/tofrodos]:Installed [OK]

*************************************************************

 

参考:

MTK源码编译 [gcc]: unknown (64-bit) [FAIL]

http://blog.csdn.net/zangcf/article/details/23023891

 

3.1.2       indexOfKey’没有声明

 基于ubuntu10.04和ubuntu14.04搭建MTK6577+Android4.04开发环境的问题与解决_第5张图片

图6

 

(1)  错误信息

 

下面给出一小部分:

frameworks/base/include/utils/KeyedVector.h:193:31:error: ‘indexOfKey’ was not declared in this scope, and no declarations werefound by argument-dependent lookup at the point of instantiation [-fpermissive]

 

frameworks/base/include/utils/AssetManager.h:

frameworks/base/include/utils/KeyedVector.h:193:31:error: ‘indexOfKey’ was not declared in this scope, and no declarations werefound by argument-dependent lookup at the point of instantiation [-fpermissive]

frameworks/base/include/utils/KeyedVector.h:193:31:error: ‘indexOfKey’ was not declared in this scope, and no declarations werefound by argument-dependent lookup at the point of instantiation [-fpermissive]

make[3]: ***[out/host/linux-x86/obj/EXECUTABLES/aapt_intermediates/AaptAssets.o] Error 1

 

(2)  解决方法

 

根据网络上给出的解决办法是,在viframeworks/base/libs/utils/Android.mk下面的内容后面加上’-fpermissive’,如下:


LOCAL_CFLAGS += -DLIBUTILS_NATIVE=1 $(TOOL_CFLAGS)  –fpermissive

但是还是一样的编译错误,然后vi frameworks/base/tools/aapt/Android.mk

 

Add '-fpermissive'to line 31:

LOCAL_CFLAGS +=-Wno-format-y2k –fpermissive

 

 

3.1.3       GetState等没有声明

(1)  错误信息

 

external/srec/tools/thirdparty/OpenFst/fst/lib/vector-fst.h:233:39:error: ‘GetState’ was not declared in this scope, and no declarations werefound by argument-dependent lookup at the point of instantiation [-fpermissive]

 

 

external/srec/tools/thirdparty/OpenFst/fst/lib/fstlib.h:

external/srec/tools/thirdparty/OpenFst/fst/lib/vector-fst.h:214:24:error: ‘Final’ was not declared in this scope, and no declarations were foundby argument-dependent lookup at the point of instantiation [-fpermissive]

 

 

external/srec/tools/thirdparty/OpenFst/fst/lib/fstlib.h:

external/srec/tools/thirdparty/OpenFst/fst/lib/vector-fst.h:325:37:error: ‘SetInputSymbols’ was not declared in this scope, and no declarationswere found by argument-dependent lookup at the point of instantiation[-fpermissive]

 

(2)  解决方法

百度,获取到的信息说是gcc和g++版本太高,所以重新安排4.4版本并重新定向。

sudo apt-getinstall gcc-4.4
sudo apt-get install g++-4.4

sudo rm -rf /usr/bin/gcc /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.1.4       没有找到zconf.h文件

(1)  错误信息

 

/usr/include/zlib.h:34:fatal error: zconf.h: No such file or directory

 

system/core/gpttool/gpttool.c:

make[3]: ***[out/host/linux-x86/obj/EXECUTABLES/gpttool_intermediates/gpttool.o] Error 1

 

(2)  解决方法

 

原因是zlib1g-dev有个头文件修改了路径,及zconf.h放到了/usr/include/x86_64-linux-gnu/,所以将其拷贝到/usr/include/下即可了

 

3.1.5       Switch.pm出错

(1)  错误信息

 

Can't locateSwitch.pm in @INC (you may need to install the Switch module) (@INC contains:/etc/perl /usr/local/lib/perl/5.18.2 /usr/local/share/perl/5.18.2/usr/lib/perl5 /usr/share/perl5 /usr/lib/perl/5.18 /usr/share/perl/5.18/usr/local/lib/site_perl .) at external/webkit/Source/WebCore/make-hash-tools.plline 23.

BEGINfailed--compilation aborted atexternal/webkit/Source/WebCore/make-hash-tools.pl line 23.

make[3]: ***[out/target/product/hsimobile77_ics2/obj/STATIC_LIBRARIES/libwebcore_intermediates/Source/WebCore/html/DocTypeStrings.cpp]Error 2

 

(2)  解决方法

安装libswitch-perl

sudo apt-getinstall libswitch-perl 

 

 

 

参考链接

http://www.linuxidc.com/Linux/2014-03/97628.htm

ubuntu13.10编译android文件系统4.0.4错误全部解析

http://blog.csdn.net/yangtalent1206/article/details/21397629

 

Ubuntu中编译Android JellyBean 4.2.1源码出现Switch.pm出错信息的解决方法

http://blog.csdn.net/michaelpp/article/details/22801953

fedroa16编译android4.0.1

http://blog.csdn.net/zlm_250/article/details/7949440

 

 


你可能感兴趣的:(基于ubuntu10.04和ubuntu14.04搭建MTK6577+Android4.04开发环境的问题与解决)