【发布时间】:2012-01-08 20:36:05
【问题描述】:
我正在尝试在 android 中包含静态 cpp 库。这个库已经编译(在 mac os 上),我有它的包含文件。
这是我的Android.mk 文件
LOCAL_PATH := $(call my-dir)
include $(call all-subdir-makefiles)
include $(CLEAR_VARS)
LOCAL_MODULE:= utils
LOCAL_SRC_FILES:= libUtils.a
LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/utils
include $(PREBUILT_STATIC_LIBRARY)
include $(CLEAR_VARS)
LOCAL_MODULE := sample
LOCAL_SRC_FILES := sample_cpp.cpp
LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)
LOCAL_STATIC_LIBRARIES := utils
LOCAL_LDLIBS := -llog
include $(BUILD_SHARED_LIBRARY)
这是Application.mk文件
APP_STL := stlport_static
APP_CPPFLAGS = -fexceptions
但每当它尝试使用 NDK 编译它时,我都会收到错误
(文件路径)/libUtils.a: 文件无法识别:文件格式无法识别 collect2: ld 返回 1 个退出状态
【问题讨论】:
-
你能提供
file libUtils.a的输出吗? -
对不起,我找不到你?输出?
-
你的库是为安卓编译的吗?如果库包含其他类型处理器(指令集)的代码,它将无法工作!
-
@bert-jan 库是在 mac os 上使用 xcode 编译的。并且适用于 iphone
-
你需要使用 Cygwin 为 Android 编译它,你这样做了吗?
标签: android c++ java-native-interface android-ndk