Ubuntu 12.04 编译Android 4.0.3 的环境配置

本来不喜欢写博客的,在Ubuntu 12.04 下编译了Android 4.0.3发现了一大堆错误,网上找了一堆的更改源码啊,Android.mk的解决方法,虽然可以编译成功,但都有点坑爹的成分,为了不误人子弟就分享出来吧。

根本原因是因为gcc的版本太高,ubuntu 12.04的系统带版本是4.6 的要求严格了,稍微有点不注意就报错。 解决方法就是降级到gcc4.4.

还有就是默认的linux系统调用的头文件路径不是标准的,例如/usr/include/i386-linux-gnu/sys

啥都别废话了, 先装下面的一堆依赖库再说

sudo apt-get -y install lib64quadmath0 lib64gomp1 lib64gcc1 libc6-amd64 libc6-dev-amd64 gcc-multilib gcc-4.6-multilib libc-bin libc-dev-bin libc6-dev libc6 build-essential linux-headers-generic linux-libc-dev libmpfr-dev libmpfr libgmp-dev libgmp uboot-mkimage u-boot-tools libglib2.0-dev libpcre3-dev git-man liberror-perl git git-core tree gperf fakeroot dkms libgsoap1  libpthread-stubs0-dev libpthread-stubs0 libx11-dev subversion vim g++ bison openjdk zlib1g-dev flex libncurses5-dev gcc-4.4 g++-4.4 g++-4.4-multilib

装完后,开始降级gcc , 放心,这不会影响到系统的情绪,就改个链接而已,不喜欢的话改回来就好

cd /usr/bin
sudo mv gcc gcc.bk
sudo ln -s gcc-4.4 gcc
sudo mv g++ g++.bk
sudo ln -s g++-4.4 g++

好了~~~完成,可以完美编译了。

以上方法可以解决下面的一堆所谓坑爹的问题,哥也傻过了,你们就别傻改代码了啦

  • 错误: “_FORTIFY_SOURCE”重定义 [-Werror]
  • external/mesa3d/src/glsl/linker.cpp:623:33: 警告: ‘virtual ir_visitor_status remap_variables(ir_instruction*, gl_shader*, hash_table*)::remap_visitor::visit(ir_dereference_variable*)’所隐藏 [-Woverloaded-virtual]
    external/mesa3d/src/glsl/linker.cpp: 在函数‘void assign_varying_locations(gl_shader_program*, gl_shader*, gl_shader*)’中:
    external/mesa3d/src/glsl/linker.cpp:1394:49: 错误: expected primary-expression before ‘,’ token
    external/mesa3d/src/glsl/linker.cpp:1394:50: 错误: ‘varyings’在此作用域中尚未声明
    external/mesa3d/src/glsl/linker.cpp:1394:58: 错误: ‘offsetof’在此作用域中尚未声明
    external/mesa3d/src/glsl/linker.cpp:1395:48: 错误: expected primary-expression before ‘,’ token
    external/mesa3d/src/glsl/linker.cpp:1412:47: 错误: expected primary-expression before ‘,’ token
    external/mesa3d/src/glsl/linker.cpp:1412:48: 错误: ‘position’在此作用域中尚未声明
    external/mesa3d/src/glsl/linker.cpp:1414:47: 错误: expected primary-expression before ‘,’ token
    external/mesa3d/src/glsl/linker.cpp:1414:48: 错误: ‘pointSize’在此作用域中尚未声明
    external/mesa3d/src/glsl/linker.cpp:1424:47: 错误: expected primary-expression before ‘,’ token
    external/mesa3d/src/glsl/linker.cpp:1424:48: 错误: ‘position’在此作用域中尚未声明
    external/mesa3d/src/glsl/linker.cpp:1428:47: 错误: expected primary-expression before ‘,’ token
    external/mesa3d/src/glsl/linker.cpp:1428:48: 错误: ‘frontFacingPointCoord’在此作用域中尚未声明
    external/mesa3d/src/glsl/linker.cpp:1431:47: 错误: expected primary-expression before ‘,’ token
    external/mesa3d/src/glsl/linker.cpp:1431:48: 错误: ‘frontFacingPointCoord’在此作用域中尚未声明
    external/mesa3d/src/glsl/linker.cpp: 在函数‘void link_shaders(const gl_context*, gl_shader_program*)’中:
    external/mesa3d/src/glsl/linker.cpp:1734:49: 错误: expected primary-expression before ‘,’ token
    external/mesa3d/src/glsl/linker.cpp:1734:50: 错误: ‘fragColor’在此作用域中尚未声明
    external/mesa3d/src/glsl/linker.cpp:1734:59: 错误: ‘offsetof’在此作用域中尚未声明
    make: *** [out/host/linux-x86/obj/STATIC_LIBRARIES/libMesa_intermediates/src/glsl/linker.o] 错误 1
  • reference ‘counts’ cannot be declared ‘mutable’ [-fpermissive]
    external/oprofile/libpp/format_output.h
  • external/llvm/lib/Support/Mutex.cpp:143: undefined reference to `pthread_mutex_trylock'
    collect2: ld returned 1 exit status
  • In file included from external/gtest/src/../include/gtest/gtest-param-test.h:157:0,
    from external/gtest/src/../include/gtest/gtest.h:69,
    from external/gtest/src/gtest_main.cc:32:
    external/gtest/src/../include/gtest/internal/gtest-param-util.h:122:11: error: ‘ptrdiff_t’ does not name a type
    In file included from external/gtest/src/../include/gtest/gtest-param-test.h:157:0,
    from external/gtest/src/../include/gtest/gtest.h:69,
    from external/gtest/src/../src/gtest.cc:34,
    from external/gtest/src/gtest-all.cc:36:
    external/gtest/src/../include/gtest/internal/gtest-param-util.h:122:11: error: ‘ptrdiff_t’ does not name a type
    In file included from external/gtest/src/gtest-all.cc:38:0:
  • host C++: llvm-rs-cc <= frameworks/compile/slang/slang_rs_export_foreach.cpp
    frameworks/compile/slang/slang_rs_export_foreach.cpp: In static member function ‘static slang::RSExportForEach* slang::RSExportForEach::Create(slang::RSContext*, const clang::FunctionDecl*)’:
    frameworks/compile/slang/slang_rs_export_foreach.cpp:247:23: error: variable ‘ParamName’ set but not used [-Werror=unused-but-set-variable]
    cc1plus: all warnings being treated as errors

相关推荐