[Android_Ubuntu编译错误]ubuntu13.10编译错误全部解析

以下是编译Android 4.0.4的常见错误,这些错误的解决办法收录自互联网。

Google group有个专门的Android Building组,有兴趣的可以加入。

除了android组解决的错误外,还有两个错误
1.external/oprofile/libpp/format_output.h:94:22: 错误: reference ‘counts’ cannot be declared ‘muta

external/oprofile/libpp/format_output.h:94:22: 错误: reference ‘counts’ cannot be declared ‘muta...

针对这种情况,需要修改external/oprofile/libpp/format_output.h:94行

mutable counts_t & counts为

counts_t & counts

2.ubuntu 10.04/ubuntu 12.04 /ubuntu 13.04 编译android 差异

1,上述都是ubuntu 64bit版本,他们编译android主要差异主要是gcc/g++,以及相关支持库的版本问题

2,ubuntu 10.04可以完美编译android 4.0.4和android 4.2的源代码

sudo apt-get install git-core gnupg flex bison gperf build-essential zip curl zlib1g-dev gcc-multilib g++-multilib libc6-dev-i386 lib32ncurses5-dev ia32-libs x11proto-core-dev libx11-dev lib32readline5-dev lib32z-dev
imagemagick

3,ubuntu 12.04编译android 4.0.4版本的时候,会出现若干报错,因为gcc版本为4.6,直接用如下方法,将gcc更新为4.4版本

环境安装包:

sudo apt-get install git-core gnupg flex
bison gperf build-essential zip curl zlib1g-dev gcc-multilib
g++-multilib libc6-dev-i386 lib32ncurses5-dev ia32-libs
x11proto-core-dev libx11-dev xsltproc lib32readline-gplv2-dev
lib32z1-dev 
libxml2-utils imagemagick

sudo
g++-4.4-multilib

sudo rm -rf /usr/bin/gcc /usr/bin/gcc

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++

这个时候是可以编译通过的,android4.2应该也可以编译通过,就没有做进一步测试了

4,ubuntu 13.04和ubuntu 13.10编译android 4.0.4版本的时候,会出现若干报错,因为gcc版本为4.7,直接用上述安装包以及修改方法,将gcc更新为4.4版本,但是仍然如下问题

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

In file included from system/extras/ext4_utils/output_file.c:30:
/usr/include/zlib.h:34: fatal error: zconf.h: 没有那个文件或目录
compilation terminated.

这样,在ubuntu 13.10都可以编译通过了

有转载这里的也有添加的。

################# Fix 1 ##########################

Error:

frameworks/base/include/utils/KeyedVector.h:193:31:
note: declarations in dependent base
‘android::KeyedVector<android::String8, android::sp<AaptDir>
>’ are not found by unqualified lookup

frameworks/base/include/utils/KeyedVector.h:193:31: note: use ‘this->indexOfKey’ instead

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

Fix:
vi frameworks/base/tools/aapt/Android.mk

Add ‘-fpermissive‘ to line 31:
LOCAL_CFLAGS += -Wno-format-y2k -fpermissive

################## Fix 2 ##########################

Error:

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

frameworks/base/include/utils/KeyedVector.h:193:31: note: declarations
in dependent base ‘android::KeyedVector<android::String8,
android::wp<android::AssetManager::SharedZip> >’ are not found
by unqualified lookup

frameworks/base/include/utils/KeyedVector.h:193:31: note: use ‘this->indexOfKey’ instead

make: *** [out/host/linux-x86/obj/STATIC_LIBRARIES/libutils_intermediates/AssetManager.o] Error 1

Fix:
vi frameworks/base/libs/utils/Android.mk

Add ‘-fpermissive‘ to line 64:
LOCAL_CFLAGS += -DLIBUTILS_NATIVE=1 $(TOOL_CFLAGS) -fpermissive

################## Fix 3 ##########################

Error:
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

Fix:
cd external/srec
wget "https://github.com/CyanogenMod/android_external_srec/commit/4d7ae7b79eda47e489669fbbe1f91ec501d42fb2.diff"
patch -p1 < 4d7ae7b79eda47e489669fbbe1f91ec501d42fb2.diff
rm -f 4d7ae7b79eda47e489669fbbe1f91ec501d42fb2.diff
cd ../..

################## Fix 3.1 ##########################

Error:
host C++: obbtool <= frameworks/base/tools/obbtool/Main.cpp
host C: parseStringTest <= external/srec/tools/parseStringTest/parseStringTest.c
<命令行>:0:0: 错误: “_FORTIFY_SOURCE”重定义 [-Werror]
frameworks/base/tools/obbtool/Main.cpp:1:0: 附注: 这是先前定义的位置

make: *** [out/host/linux-x86/obj/EXECUTABLES/obbtool_intermediates/Main.o] 错误 1

Fix:

vi build/core/combo/HOST_linux-x86.mk  line56
Add  -U_FORTIFY_SOURCE

HOST_GLOBAL_CFLAGS += -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=0

########################ADD ERROR##################################

I started getting this error while compiling CyanogenMod 9 (Android 4.0.x) last week:

dalvik/vm/native/dalvik_system_Zygote.cpp: In function ‘int setrlimitsFromArray(ArrayObject*)’:
dalvik/vm/native/dalvik_system_Zygote.cpp:199:19: error: aggregate ‘setrlimitsFromArray(ArrayObject*)::rlimit rlim’ has incomplete type and cannot be defined
     struct rlimit rlim;
                   ^
dalvik/vm/native/dalvik_system_Zygote.cpp:222:43: error: ‘setrlimit’ was not declared in this scope
         err = setrlimit(contents[0], &rlim);
                                           ^
make: *** [out/host/linux-x86/obj/SHARED_LIBRARIES/libdvm_intermediates/native/dalvik_system_Zygote.o] Error 1
make: *** Waiting for unfinished jobs....

I’m not sure if it’s due to a recent Arch Linux change or what, but it seems the fix is simply to add #include <sys/resource.h>to dalvik/vm/native/dalvik_system_Zygote.cpp. Here’s a diff:

diff --git a/vm/native/dalvik_system_Zygote.cpp b/vm/native/dalvik_system_Zygote.cpp
index 8224656..f4102e8 100644
--- a/vm/native/dalvik_system_Zygote.cpp
+++ b/vm/native/dalvik_system_Zygote.cpp
@@ -19,6 +19,7 @@
  */
 #include "Dalvik.h"
 #include "native/InternalNativePriv.h"
+#include <sys/resource.h>

 #include
 #if (__GNUC__ == 4 && __GNUC_MINOR__ == 7)

################## Fix 4 ##########################

Error:
development/tools/emulator/opengl/host/tools/emugen/main.cpp:79:9: error: ‘optind’ was not declared in this scope
development/tools/emulator/opengl/host/tools/emugen/main.cpp:92:45: error: ‘optind’ was not declared in this scope
make: *** [out/host/linux-x86/obj/EXECUTABLES/emugen_intermediates/main.o] Error 1

Fix:
vi development/tools/emulator/opengl/host/tools/emugen/main.cpp

Add ‘#include <getopt.h>‘ to list of includes:
#include <getopt.h>

################## Fix 5 ##########################

Error:
host C++: liboprofile_pp <= external/oprofile/libpp/arrange_profiles.cpp
In file included from external/oprofile/libpp/arrange_profiles.cpp:24:0:
external/oprofile/libpp/format_output.h:94:22: error: reference ‘counts’ cannot be declared ‘mutable’ [-fpermissive]
make: *** [out/host/linux-x86/obj/STATIC_LIBRARIES/liboprofile_pp_intermediates/arrange_profiles.o] Error 1

Fix:
vi external/oprofile/libpp/format_output.h

Remove ‘mutable‘ from ‘mutable counts_t & counts;‘ on line 94:
counts_t & counts;

################## Fix 6 ##########################

Error:
development/tools/emulator/opengl/shared/OpenglCodecCommon/GLSharedGroup.cpp:345:65:   required from here

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

frameworks/base/include/utils/KeyedVector.h:193:31: note: declarations
in dependent base ‘android::KeyedVector<unsigned int,
ShaderData*>’ are not found by unqualified lookup

frameworks/base/include/utils/KeyedVector.h:193:31: note: use ‘this->indexOfKey’ instead

make: *** [out/host/linux-x86/obj/STATIC_LIBRARIES/libOpenglCodecCommon_intermediates/GLSharedGroup.o] Error 1

Fix:
vi development/tools/emulator/opengl/Android.mk

Add ‘-fpermissive‘ to line 25:
EMUGL_COMMON_CFLAGS := -DWITH_GLES2 -fpermissive

################## Fix 7 ##########################

Error:
/usr/bin/ld: note: ‘XInitThreads‘ is defined in DSO /lib/libX11.so.6 so try adding it to the linker command line
/lib/libX11.so.6: could not read symbols: Invalid operation
collect2: error: ld returned 1 exit status
make: *** [out/host/linux-x86/obj/EXECUTABLES/emulator_renderer_intermediates/emulator_renderer] Error 1

Fix:
vi development/tools/emulator/opengl/host/renderer/Android.mk

Add new entry ‘LOCAL_LDLIBS += -lX11‘ after line 6 as shown:
LOCAL_SRC_FILES := main.cpp
LOCAL_CFLAGS    += -O0 -g
LOCAL_LDLIBS += -lX11

#ifeq ($(HOST_OS),windows)
#LOCAL_LDLIBS += -lws2_32

################## Fix 8 ##########################

Error:
external/llvm/include/llvm/ADT/PointerUnion.h:56:10: error: enumeral
mismatch in conditional expression:
‘llvm::PointerLikeTypeTraits<llvm::PointerUnion<clang::Stmt*,
const clang::Type*> >::<anonymous enum>’ vs
‘llvm::PointerLikeTypeTraits<clang::ObjCInterfaceDecl*>::<anonymous

enum>’ [-Werror]
cc1plus: all warnings being treated as errors
make: *** [out/host/linux-x86/obj/EXECUTABLES/llvm-rs-cc_intermediates/slang_rs.o] Error 1

Fix:
vi frameworks/compile/slang/Android.mk

Remove ‘-Werror‘ from line 22:
local_cflags_for_slang := -Wno-sign-promo -Wall -Wno-unused-parameter

################## Fix 9 ##########################

Error:
frameworks/base/libs/rs/rsFont.cpp:224:76:   required from here

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

frameworks/base/include/utils/KeyedVector.h:193:31: note: declarations
in dependent base ‘android::KeyedVector<unsigned int,
android::renderscript::Font::CachedGlyphInfo*>’ are not found by
unqualified lookup

frameworks/base/include/utils/KeyedVector.h:193:31: note: use ‘this->indexOfKey’ instead

make: *** [out/host/linux-x86/obj/STATIC_LIBRARIES/libRS_intermediates/rsFont.o] Error 1

Fix:
vi frameworks/base/libs/rs/Android.mk

Add ‘-fpermissive‘ to line 183
LOCAL_CFLAGS += -Werror -Wall -Wno-unused-parameter -Wno-unused-variable -fpermissive

################## Fix 10 #########################

Error:
external/mesa3d/src/glsl/linker.cpp:1394:49: error: expected primary-expression before ‘,’ token
......
external/mesa3d/src/glsl/linker.cpp:1734:59: error: ‘offsetof’ was not declared in this scope
make: *** [out/host/linux-x86/obj/STATIC_LIBRARIES/libMesa_intermediates/src/glsl/linker.o] Error 1

Fix:
vi external/mesa3d/src/glsl/linker.cpp

Add ‘#include <stddef.h>‘ to list of includes as shown: 
#include <climits>
#include <stddef.h>
#include <pixelflinger2/pixelflinger2_interface.h>

################## Fix 11 #########################

Error:
external/gtest/src/../include/gtest/gtest-param-test.h:287:58: note:
‘template<class Container>
testing::internal::ParamGenerator<typename Container::value_type>
testing::ValuesIn(const Container&)’ declared here, later in the
translation unit
make: *** [out/host/linux-x86/obj/STATIC_LIBRARIES/libgtest_host_intermediates/gtest-all.o] Error 1

Two fixes required:
1)
vi external/gtest/src/Android.mk

Add ‘-fpermissive‘ to lines 52 and 70 (both lines contain same info)
LOCAL_CFLAGS += -O0 -fpermissive

2)
vi external/gtest/include/gtest/internal/gtest-param-util.h

Add ‘#include <stddef.h>‘ to list of includes as shown:
#include <vector>
#include <cstddef>
#include <gtest/internal/gtest-port.h>

################## Fix 12 #########################

Error:

host Executable: test-librsloader (out/host/linux-x86/obj/EXECUTABLES/test-librsloader_intermediates/test-librsloader)
out/host/linux-x86/obj/STATIC_LIBRARIES/libLLVMSupport_intermediates/libLLVMSupport.a(Signals.o):在函数‘PrintStackTrace’中:
/home/crow/works/Android_src/external/llvm/lib/Support/Unix/Signals.inc:219:对‘dladdr’未定义的引用
/home/crow/works/Android_src/external/llvm/lib/Support/Unix/Signals.inc:231:对‘dladdr’未定义的引用
out/host/linux-x86/obj/STATIC_LIBRARIES/libLLVMSupport_intermediates
/libLLVMSupport.a(Threading.o):在函数‘llvm::llvm_execute_on_thread(void
(*)(void*), void*, unsigned int)’中:
/home/crow/works/Android_src/external/llvm/lib/Support/Threading.cpp:96:对‘pthread_create’未定义的引用
/home/crow/works/Android_src/external/llvm/lib/Support/Threading.cpp:100:对‘pthread_join’未定义的引用
/home/crow/works/Android_src/external/llvm/lib/Support/Threading.cpp:91:对‘pthread_attr_setstacksize’未定义的引用
out/host/linux-x86/obj/STATIC_LIBRARIES/libLLVMSupport_intermediates
/libLLVMSupport.a(Mutex.o):在函数‘llvm::sys::MutexImpl::MutexImpl(bool)’中:
/home/crow/works/Android_src/external/llvm/lib/Support/Mutex.cpp:69:对‘pthread_mutexattr_init’未定义的引用
/home/crow/works/Android_src/external/llvm/lib/Support/Mutex.cpp:75:对‘pthread_mutexattr_settype’未定义的引用
/home/crow/works/Android_src/external/llvm/lib/Support/Mutex.cpp:80:对‘pthread_mutexattr_setpshared’未定义的引用
/home/crow/works/Android_src/external/llvm/lib/Support/Mutex.cpp:89:对‘pthread_mutexattr_destroy’未定义的引用
out/host/linux-x86/obj/STATIC_LIBRARIES/libLLVMSupport_intermediates
/libLLVMSupport.a(Mutex.o):在函数‘llvm::sys::MutexImpl::tryacquire()’中:
/home/crow/works/Android_src/external/llvm/lib/Support/Mutex.cpp:143:对‘pthread_mutex_trylock’未定义的引用
collect2: 错误: ld 返回 1
make: *** [out/host/linux-x86/obj/EXECUTABLES/test-librsloader_intermediates/test-librsloader] 错误 1

Fix:

$vi external/llvm/llvm-host-build.mk +
LOCAL_LDLIBS := -lpthread -ldl

时间: 2024-11-05 11:54:49

[Android_Ubuntu编译错误]ubuntu13.10编译错误全部解析的相关文章

Cocos2dx 3.10版编译安卓报卷标错误

  环境: Java-sdk 1.7 Python2.7 Cocos2dx-3.10 Lua5.1 VC++2005-2013 Ant 1.10.1 android-ndk-r10d   1.错误截图 C++编译完成,生成apk包出错 2.解决过程 2.1最初怀疑磁盘问题,格式化磁盘/修复磁盘坏道也没用,尝试几台机器有同样的错误,排除磁盘问题. 2.2 用cocos命令行手工执行编译,编译成功,推测可能是Python执行cmd命令的BUG 2.3 找到build_android.py查看py执行

Delphi - 10.1编译OSX10.12程序遇到错误解决了!

昨天,尝试Delphi的跨平台开发功能,在windows10下,做了一个控制台程序,发布目标平台是OSX10.12,中间配置过程都非常顺利,没有任何错误,但是当编译运行时候出现下面错误: [dccosx Fatal Error] F2084 Internal Error: AV0CAF8963-R00000014-0 在网上搜寻解决方法,发现大多数建议都是降低OSX SDK版本,于是推测,可能是Delphi版本和OSX的SDK版本不匹配造成的! 今天,我安装了Delphi10.2.3,随后重新安

使用AndroidStudio编译NDK的方法及错误解决方式

參考资料: [android ndk]macos环境下Android Studio中利用gradle编译jni模块及配置:http://demo.netfoucs.com/ashqal/article/details/21869151 ANDROID STUDIO, GRADLE AND NDK INTEGRATION:http://ph0b.com/android-studio-gradle-and-ndk-integration/ Gradle Plugin User Guide:http:

编译php时遇到的错误

error 1 checking for xml2-config path...configure: error: xml2-config not found. Please check your libxml2 installation. lib库没装  先用 yum search 名字 看是否能搜到名字 ,找到名字后 把软件包 开发包装上 解决办法 yum install libxml2-devel.x86_64 error 2 checking for pkg-config... /usr

【转】Linux CentOS内核编译:下载CentOS源码、编译2.6.32-220的错误(apic.c:819 error &#39;numi_watchdog&#39; undeclared)

一.下载CentOS源码 1.1 查看CentOS版本 cat /etc/issue 1.2 查看Linux内核版本 uname -r 1.3 下载 文件名:kernel-2.6.32-220.el6.src.rpm 下载地址:http://vault.centos.org/6.2/os/Source/SPackages/ 官网:http://vault.centos.org/ 1.4 从kernel-2.6.32-220.el6.src.rpm获取源码 1. rpm -i kernel-2.6

windows下编译java源文件的编码错误

import java.util.Arrays;public class ArrayAsAReference{ public static void main(String[] args) { int[] arr = null; System.out.println(arr); arr = new int[]{1, 2, 3, 4}; // 静态创建数组对象 System.out.println(Arrays.toString(arr)); int[] prices; prices = new

VS编译duilib项目时候的错误解决方法整理

@1:找不到Riched20.lib 用everything等软件搜索下磁盘,找到所在的目录添加到vs的库目录即可,我得是C:\Program Files (x86)\Microsoft SDKs\Windows\v7.1A\Lib:其他的vs版本可能不一样,自行搜索 @2: "IDispatchEx": 重定义:不同的基类型 点击打开链接 UIFlash.h行: #import "..\Utils/Flash11.tlb" raw_interfaces_only,

解决编译GCC内存不足的错误

近期在使用阿里和腾讯的云服务器,由于只是测试用所以只租用了廉价512的内存,在编译gcc时遇到错误,表面上看只是编译错误,并且原因不明,纠结了几次之后猜测应该是由于系统资源不足导致的,所以尝试增加系统的swap分区,这里需要检查两个地方 一.修改swappiness 1.查看你的系统里面的swappiness$ cat /proc/sys/vm/swappiness不出意外的话,你应该看到是 60,在阿里云看到的可能是0,那么就需要修改2.修改swappiness值$ sudo sysctl v

设置VS编译或部署时遇到错误提示是否继续运行

默认情况下,vs2010按F5进行编译,如果编译时发现有错误,vs会提示是否继续运行. 如果手贱不小心点了继续运行且不再提示,结果现在就算编译出错也不提示. 会照成整个项目编译完成后才提示错误信息非常浪费时间!下面是给手残党的配置图! 设置VS编译或部署时遇到错误提示是否继续运行