ubuntu11.10 64bit 编译android 4.0

前言:

据说google内部使用的的ubuntu版本始终是10.4

而我一直使用的编译2.3Gingerbread 11.04下补充安装uuid-devliblzo2-dev两个库就可以直接编译4.0了。

问题是我们公司编译服务器上安装的是11.10,其对应的gcc版本是 4.6.1,一个显著的变化是编译查错级别提高了。

为保持ubuntu的统一性,根据不修改gcc版本,修改相应出错代码的原则进行编译。 

;=========0.安装JDK 6

android官网指定的源居然提示找不到jdk安装文件,提示E:Package 'sun-java6-jdk' has no installation candidate

解决:添加一个源:debhttp://us.archive.ubuntu.com/ubuntu/ hardy multiverse

方法:打开源列表: sudo vim/etc/apt/sources.list

在最后一行添加deb http://us.archive.ubuntu.com/ubuntu/ hardy multiverse

更新apt源: sudo apt-get update

安装sun-java6-jdk:  sudo apt-get install sun-java6-jdk

下载完成后,在提示界面按tab键选择确认。(如果ssh shell窗口安装的,jdk安装图形界面看不到,直接tab键选择,回车键接受,就OK了)

 

;===========1.安装lib

1.1 sudo apt-get install git-core gnupgflex bison gperf build-essential \

zip curl zlib1g-dev libc6-devlib32ncurses5-dev ia32-libs \

x11proto-core-dev libx11-dev lib32z-dev \

libgl1-mesa-dev g++-multilib mingw32tofrodos python-markdown \

libxml2-utils xsltproc -y

 

为保证安装成功,再次运行上述命令,检查是否有漏装的,可能与安装顺序的依赖关系有关。比如我再次运行时,如下提示:

The following extra packages will beinstalled:

 libpthread-stubs0 libpthread-stubs0-dev libxau-dev libxcb1-devlibxdmcp-dev libxext-dev mesa-common-dev

The following packages will be REMOVED:

 libpthread-stubs0:i386 libpthread-stubs0-dev:i386 libx11-dev:i386libxau-dev:i386 libxcb1-dev:i386 libxdmcp-dev:i386

The following NEW packages will beinstalled:

 libgl1-mesa-dev libpthread-stubs0 libpthread-stubs0-dev libx11-devlibxau-dev libxcb1-dev libxdmcp-dev libxext-dev mesa-common-dev

 

lib32readline5-dev 这个找不到,建议安装 --->  lib32readline-gplv2-dev

sudo apt-get installlib32readline-gplv2-dev 

sudo apt-get install uuid-dev  #这个库也要安装。

 

;============2.报错/usr/bin/ld: cannot find -llzo2

#这个是缺lib

sudo apt-get install liblzo2-dev:i386  #注意一定要带:i386,否则可能报 cannot find-llzo2

#不能使用普通版本liblzo2-dev,会报skipping incompatible然后仍然 /usr/bin/ld: cannot find -llzo2

#如果已经安装了liblzo2-dev,再运行上面的命令会卸载一些gcc等,需要重新安装1.1里面的那一堆。

 

;=============3.报错:error: "_FORTIFY_SOURCE" redefined [-Werror]

host C++: obbtool <= frameworks/base/tools/obbtool/Main.cpp

<command-line>:0:0: error:"_FORTIFY_SOURCE" redefined [-Werror]

<built-in>:0:0: note: this is thelocation of the previous definition

解决方法:

修改源码目录下/build/core/combo/HOST_linux-x86.mk文件:

将以下语句

HOST_GLOBAL_CFLAGS += -D_FORTIFY_SOURCE=0

修改为

HOST_GLOBAL_CFLAGS += -U_FORTIFY_SOURCE-D_FORTIFY_SOURCE=0

 

;===============4.报错:frameworks/compile/slang/slang_rs_export_foreach.cpp:247:23: error: variable ParamName set but not used [-Werror=unused-but-set-variable]

解决方法: vimframeworks/compile/slang/Android.mk去掉-Werror

 

这类问题的一般通用解决方法:

遇到错误:cc1plus:warnings being treated as errors

主要原因是 MakefileAndroid.mk里面 gcc的参数多了一个 "-Werror"

找到出错的模块下的make文件,看Make文件里面有没有“-Werror",如果有的话将其删除。重新编译即可。

  

;===============5.报错: mesa3d/src/glsl/linker.cpp:1394:49: error: expectedprimary-expression before

解决方法:

"#include <stddef.h>"添加到 linker.cpp文件头部。

 

 

;=================6.报错:external/oprofile/libpp/format_output.h:94:22: error: reference ‘counts’ cannot be declared

解决方法:需要修改external/oprofile/libpp/format_output.h:94

mutable counts_t & counts

counts_t & counts

 

;=============7.报错 Mutex.cpp:143: undefined reference to `pthread_mutex_trylock' llvm/lib/Support/Unix/Signals.inc:219:undefined reference to `dladdr'

解决方法:

 $viexternal/llvm/llvm-host-build.mk

 LOCAL_LDLIBS := -lpthread -ldl

 

;=============8.报错 /gtest/internal/gtest-param-util.h:122:11: error: ‘ptrdiff_t’ does not name a type

解决方法:

 $viexternal/gtest/src/../include/gtest/internal/gtest-param-util.h

 #include <cstddef>

 

我的电脑修改了上面几处就编译成功了。

你可能感兴趣的:(android 4.0)