我正在使用https://github.com/eighthave/openssl-android给出的开放源码来构建一个可以在安卓项目中使用的库。
根据README.txt上的说明,我能够将它编译到Android平台版本2.2 (level -8)上。
但我的应用程序要求它与2.1 (7级)兼容。
我在default.properties文件( https://github.com/eighthave/openssl-android/blob/master/default.properties )中尝试了以下选项
1)设置target=android-7
2)设置target=android-5
但是当我使用ndk-build命令编译它时,它给出了以下错误
Compile thumb : crypto <= dsa_vrf.c
Compile thumb : crypto <= dso_dl.c
Compile thumb : crypto <= dso_dlfcn.c
/Crypto/openssl-android/crypto/dso/dso_dlfcn.c: In function 'dlfcn_pathbyaddr':
/Crypto/openssl-android/crypto/dso/dso_dlfcn.c:445: error: 'Dl_info' undeclared (first use in this function)
/Crypto/openssl-android/crypto/dso/dso_dlfcn.c:445: error: (Each undeclared identifier is reported only once
/Crypto/openssl-android/crypto/dso/dso_dlfcn.c:445: error: for each function it appears in.)
/Crypto/openssl-android/crypto/dso/dso_dlfcn.c:445: error: expected ';' before 'dli'
/Crypto/openssl-android/crypto/dso/dso_dlfcn.c:455: error: 'dli' undeclared (first use in this function)
make: *** [obj/local/armeabi/objs/crypto/dso/dso_dlfcn.o] Error 1根据错误消息-未定义Dl_info。但是如果我们转到dso_dlfcn.c文件,已经提供了该结构的定义。(https://github.com/eighthave/openssl-android/blob/master/crypto/dso/dso_dlfcn.c)
这段代码在默认属性文件中编译为target=android-8,但不是为android-7或android-5编译的。
请求您帮助我解决此错误。让我知道为了编译android 2.1平台需要做哪些修改。
提前谢谢。
发布于 2011-12-23 01:57:32
尝试将以下代码段包含到dso_dlfcn.c中:
typedef struct {
const char *dli_fname; /* Pathname of shared object that
contains address */
void *dli_fbase; /* Address at which shared object
is loaded */
const char *dli_sname; /* Name of nearest symbol with address
lower than addr */
void *dli_saddr; /* Exact address of symbol named
in dli_sname */
} Dl_info;
int dladdr(const void *addr, Dl_info *info) { return 0; }之前:
#ifdef __linux
# ifndef _GNU_SOURCE
# define _GNU_SOURCE /* make sure dladdr is declared */
# endif
#endif在此之后,在我的例子中,库就构建完成了。
发布于 2015-04-10 15:15:58
尝试使用最新的NDK版本安装,并相应地更新Application.mk文件。
LOCAL_PATH := $(call my-dir)
APP_PLATFORM := android-19
NDK_TOOLCHAIN_VERSION := clang
APP_ABI := armeabi-v7a
APP_STL := gnustl_static
APP_CPPFLAGS += -frtti
APP_CPPFLAGS += -fexceptions
APP_CPPFLAGS += -DANDROID
APP_PROJECT_PATH := $(shell pwd)
APP_BUILD_SCRIPT := $(LOCAL_PATH)/../Android.mk以上两个问题将得到解决。
发布于 2015-08-16 07:24:44
我对@Yuri的解决方案有一个问题,不得不稍微改进一下。我的APP_ABI在Application.mk中设置为all。在我的例子中,这意味着在armeabi和armeabi-v7a中,我也在为x86和mips构建。我还在android sdk中安装了android-9目标,以便在其他项目中使用。从android-9开始,ndk支持x86和mips。正如文档中所写的,当ndk-build开始构建这些目标时,它将自动切换到android-9目标。然后呢?-是的,它将无法编译:-)。以下是我的解决方案:
local_c_flags := -DNO_WINDOWS_BRAINDEATH。在这行代码之后,必须将这段http://pastebin.com/7euUVD7A.#ifdef __linux之后,而不是if defined之后。
https://stackoverflow.com/questions/8378493
复制相似问题