Android ndk 如何将libc添加到android应用程序?
我正在写一个C代码,我希望用ndk在android上运行。我在代码中有glibc库,据我所知,很难直接移植。因此,我尝试从github中的仿生存储库使用libc。在构建它的过程中,我面临着许多错误 谁能解释一下如何将libc包含在一个循序渐进的过程中(或者指导我找到一些源代码)。我搜索了很多,但在任何地方都找不到教程 以下是我得到的错误:Android ndk 如何将libc添加到android应用程序?,android-ndk,glibc,libc,bionic,Android Ndk,Glibc,Libc,Bionic,我正在写一个C代码,我希望用ndk在android上运行。我在代码中有glibc库,据我所知,很难直接移植。因此,我尝试从github中的仿生存储库使用libc。在构建它的过程中,我面临着许多错误 谁能解释一下如何将libc包含在一个循序渐进的过程中(或者指导我找到一些源代码)。我搜索了很多,但在任何地方都找不到教程 以下是我得到的错误: In file included from jni/libc/private/ScopedPthreadMutexLocker.h:22:0,
In file included from jni/libc/private/ScopedPthreadMutexLocker.h:22:0,
from jni/libc/bionic/malloc_debug_common.cpp:47:
jni/libc/private/bionic_macros.h:27:31: warning: defaulted and deleted functions only available with -std=c++11 or -std=gnu++11 [enabled by default]
TypeName(const TypeName&) = delete; \
^
jni/libc/private/ScopedPthreadMutexLocker.h:37:3: note: in expansion of macro 'DISALLOW_COPY_AND_ASSIGN'
DISALLOW_COPY_AND_ASSIGN(ScopedPthreadMutexLocker);
^
jni/libc/private/bionic_macros.h:28:37: warning: defaulted and deleted functions only available with -std=c++11 or -std=gnu++11 [enabled by default]
void operator=(const TypeName&) = delete
^
jni/libc/private/ScopedPthreadMutexLocker.h:37:3: note: in expansion of macro 'DISALLOW_COPY_AND_ASSIGN'
DISALLOW_COPY_AND_ASSIGN(ScopedPthreadMutexLocker);
^
In file included from jni/libc/bionic/jemalloc.h:20:0,
from jni/libc/bionic/malloc_debug_common.cpp:50:
jni/libc/jemalloc/jemalloc.h:108:36: error: declaration of C function 'size_t malloc_usable_size(void*)' conflicts with
# define JEMALLOC_CXX_THROW throw()
^
jni/libc/jemalloc/jemalloc.h:231:43: note: in expansion of macro 'JEMALLOC_CXX_THROW'
JEMALLOC_USABLE_SIZE_CONST void *ptr) JEMALLOC_CXX_THROW;
^
In file included from /home/yogi/android-ndk/platforms/android-21/arch-arm/usr/include/string.h:33:0,
from /home/yogi/android-ndk/platforms/android-21/arch-arm/usr/include/signal.h:35,
from /home/yogi/android-ndk/platforms/android-21/arch-arm/usr/include/pthread.h:33,
from jni/libc/bionic/malloc_debug_common.h:36,
from jni/libc/bionic/malloc_debug_common.cpp:40:
/home/yogi/android-ndk/platforms/android-21/arch-arm/usr/include/malloc.h:36:15: error: previous declaration 'size_t malloc_usable_size(const void*)' here
extern size_t malloc_usable_size(const void* p);
^
jni/libc/bionic/malloc_debug_common.cpp:51:27: error: 'je_calloc' was not declared in this scope
#define Malloc(function) je_ ## function
^
jni/libc/bionic/malloc_debug_common.cpp:67:3: note: in expansion of macro 'Malloc'
Malloc(calloc),
^
jni/libc/bionic/malloc_debug_common.cpp:51:27: error: 'je_free' was not declared in this scope
#define Malloc(function) je_ ## function
^
jni/libc/bionic/malloc_debug_common.cpp:68:3: note: in expansion of macro 'Malloc'
Malloc(free),
^
jni/libc/bionic/malloc_debug_common.cpp:51:27: error: 'je_malloc' was not declared in this scope
#define Malloc(function) je_ ## function
^
jni/libc/bionic/malloc_debug_common.cpp:70:3: note: in expansion of macro 'Malloc'
Malloc(malloc),
^
jni/libc/bionic/malloc_debug_common.cpp:51:27: error: 'je_malloc_usable_size' was not declared in this scope
#define Malloc(function) je_ ## function
^
jni/libc/bionic/malloc_debug_common.cpp:71:3: note: in expansion of macro 'Malloc'
Malloc(malloc_usable_size),
^
jni/libc/bionic/malloc_debug_common.cpp:51:27: error: 'je_posix_memalign' was not declared in this scope
#define Malloc(function) je_ ## function
^
jni/libc/bionic/malloc_debug_common.cpp:73:3: note: in expansion of macro 'Malloc'
Malloc(posix_memalign),
^
jni/libc/bionic/malloc_debug_common.cpp:51:27: error: 'je_realloc' was not declared in this scope
#define Malloc(function) je_ ## function
^
jni/libc/bionic/malloc_debug_common.cpp:77:3: note: in expansion of macro 'Malloc'
Malloc(realloc),
^
jni/libc/bionic/malloc_debug_common.cpp:51:27: error: 'je_valloc' was not declared in this scope
#define Malloc(function) je_ ## function
^
jni/libc/bionic/malloc_debug_common.cpp:79:3: note: in expansion of macro 'Malloc'
Malloc(valloc),
^
jni/libc/bionic/malloc_debug_common.cpp: In function 'void get_malloc_leak_info(uint8_t**, size_t*, size_t*, size_t*, size_t*)':
jni/libc/bionic/malloc_debug_common.cpp:191:96: error: 'je_malloc' was not declared in this scope
HashEntry** list = static_cast<HashEntry**>(Malloc(malloc)(sizeof(void*) * g_hash_table.count));
^
jni/libc/bionic/malloc_debug_common.cpp:214:22: error: 'je_free' was not declared in this scope
Malloc(free)(list);
^
jni/libc/bionic/malloc_debug_common.cpp:236:20: error: 'je_free' was not declared in this scope
Malloc(free)(list);
^
jni/libc/bionic/malloc_debug_common.cpp: In function 'void free_malloc_leak_info(uint8_t*)':
jni/libc/bionic/malloc_debug_common.cpp:240:20: error: 'je_free' was not declared in this scope
Malloc(free)(info);
^
jni/libc/bionic/malloc_debug_common.cpp: In function 'size_t malloc_usable_size(const void*)':
jni/libc/bionic/malloc_debug_common.cpp:262:53: error: declaration of C function 'size_t malloc_usable_size(const void*)' conflicts with
extern "C" size_t malloc_usable_size(const void* mem) {
^
In file included from jni/libc/bionic/jemalloc.h:20:0,
from jni/libc/bionic/malloc_debug_common.cpp:50:
jni/libc/jemalloc/jemalloc.h:70:33: error: previous declaration 'size_t malloc_usable_size(void*)' here
# define je_malloc_usable_size malloc_usable_size
^
jni/libc/jemalloc/jemalloc.h:230:41: note: in expansion of macro 'je_malloc_usable_size'
JEMALLOC_EXPORT size_t JEMALLOC_NOTHROW je_malloc_usable_size(
^
make: *** [obj/local/armeabi-v7a/objs/c/bionic/malloc_debug_common.o] Error 1
在jni/libc/private/ScopedPthreadMutexLocker.h:22:0中包含的文件中,
来自jni/libc/bionic/malloc_debug_common.cpp:47:
jni/libc/private/bionic_macros.h:27:31:警告:默认和删除的函数仅在-std=c++11或-std=gnu++11[默认启用]下可用
TypeName(consttypename&)=删除\
^
jni/libc/private/ScopedPthreadMutexLocker.h:37:3:注意:在宏“DISALLOW_COPY_和_ASSIGN”的扩展中
不允许复制和分配(ScopedPthreadMutexLocker);
^
jni/libc/private/bionic_macros.h:28:37:警告:默认和删除的函数仅在-std=c++11或-std=gnu++11[默认启用]下可用
void运算符=(const TypeName&)=删除
^
jni/libc/private/ScopedPthreadMutexLocker.h:37:3:注意:在宏“DISALLOW_COPY_和_ASSIGN”的扩展中
不允许复制和分配(ScopedPthreadMutexLocker);
^
在jni/libc/bionic/jemalloc.h:20:0中包含的文件中,
来自jni/libc/bionic/malloc_debug_common.cpp:50:
jni/libc/jemalloc/jemalloc.h:108:36:错误:C函数“size\t malloc\u usable\u size(void*)”的声明与
#定义JEMALLOC_CXX_THROW()
^
jni/libc/jemalloc/jemalloc.h:231:43:注意:在宏“jemalloc\u CXX\u THROW”的扩展中
JEMALLOC_可用_大小_CONST void*ptr)JEMALLOC_CXX_THROW;
^
在/home/yogi/android ndk/platforms/android-21/arch arm/usr/include/string.h:33:0中包含的文件中,
from/home/yogi/android-ndk/platforms/android-21/arch-arm/usr/include/signal.h:35,
from/home/yogi/android-ndk/platforms/android-21/arch-arm/usr/include/pthread.h:33,
来自jni/libc/bionic/malloc_debug_common.h:36,
来自jni/libc/bionic/malloc_debug_common.cpp:40:
/home/yogi/android-ndk/platforms/android-21/arch-arm/usr/include/malloc.h:36:15:错误:前面的声明“size\t malloc\u usable\u size(const void*)”
外部大小\u t malloc\u可用大小(const void*p);
^
jni/libc/bionic/malloc_debug_common.cpp:51:27:错误:“je_calloc”未在此范围内声明
#定义Malloc(函数)je###函数
^
jni/libc/bionic/malloc_debug_common.cpp:67:3:注意:在宏“malloc”的扩展中
马洛克(calloc),
^
jni/libc/bionic/malloc_debug_common.cpp:51:27:错误:“je_free”未在此范围内声明
#定义Malloc(函数)je###函数
^
jni/libc/bionic/malloc_debug_common.cpp:68:3:注意:在宏“malloc”的扩展中
马洛克(免费),
^
jni/libc/bionic/malloc_debug_common.cpp:51:27:错误:“je_malloc”未在此范围内声明
#定义Malloc(函数)je###函数
^
jni/libc/bionic/malloc_debug_common.cpp:70:3:注意:在宏“malloc”的扩展中
马洛克(Malloc),
^
jni/libc/bionic/malloc_debug_common.cpp:51:27:错误:“je_malloc_usable_size”未在此范围内声明
#定义Malloc(函数)je###函数
^
jni/libc/bionic/malloc_debug_common.cpp:71:3:注意:在宏“malloc”的扩展中
Malloc(Malloc\u可用大小),
^
jni/libc/bionic/malloc_debug_common.cpp:51:27:错误:“je_posix_memalign”未在此范围内声明
#定义Malloc(函数)je###函数
^
jni/libc/bionic/malloc_debug_common.cpp:73:3:注意:在宏“malloc”的扩展中
Malloc(posix_memalign),
^
jni/libc/bionic/malloc_debug_common.cpp:51:27:错误:“je_realloc”未在此范围内声明
#定义Malloc(函数)je###函数
^
jni/libc/bionic/malloc_debug_common.cpp:77:3:注意:在宏“malloc”的扩展中
Malloc(realloc),
^
jni/libc/bionic/malloc_debug_common.cpp:51:27:错误:“je_valloc”未在此范围内声明
#定义Malloc(函数)je###函数
^
jni/libc/bionic/malloc_debug_common.cpp:79:3:注意:在宏“malloc”的扩展中
马洛克(瓦洛克),
^
jni/libc/bionic/malloc_debug_common.cpp:在函数“void get_malloc_leak_info”(uint8_t**,size_t*,size_t*,size_t*)中:
jni/libc/bionic/malloc_debug_common.cpp:191:96:错误:“je_malloc”未在此范围内声明
HashEntry**list=static_cast(Malloc(Malloc)(sizeof(void*)*g_hash_table.count));
^
jni/libc/bionic/malloc_debug_common.cpp:214:22:错误:“je_free”未在此范围内声明
马洛克(免费)(名单);
^
jni/libc/bionic/malloc_debug_common.cpp:236:20:错误:“je_free”未在此范围内声明
马洛克(免费)(名单);
^
jni/libc/bionic/malloc_debug_common.cpp:在函数“void free_malloc_leak_info(uint8_t*)”中:
jni/libc/bionic/malloc_debug_common.cpp:240:20:错误:“je_free”未在此范围内声明
Malloc(免费)(信息);
^
jni/libc/bionic/malloc_debug_common.cpp:在函数“size_t malloc_usable_size(const void*)”中:
jni/libc/bionic/malloc_调试公司