提升Android,ndk-build无法创建.so / headers无法找到

时间:2013-01-16 06:17:45

标签: android boost android-ndk cocos2d-x

我一直在尝试按照以下说明将boost链接到我的Android应用程序:

Include Boost C++ library in android

这似乎非常简洁明智。不幸的是,经过几天的尝试后,我无法看到我做错了什么,因为最终的结果是ndk-build返回“没有这样的文件或目录”关于我试图包含的提升标题。

在构建我需要的boost库之后,我将它们复制到proj.android/jni/boost/include和proj.android/jni/boost/lib中。然后我在jni中创建了一个名为boost-build的目录,在那里我创建了一个Android.mk来处理定义模块以链接到libboost_serialization静态库(这是我唯一感兴趣的升级库)。

LOCAL_PATH:= $(call my-dir)

# serialization
include $(CLEAR_VARS)

# I'm not sure this is necessary / helpful, but I've tried without it, as well
LOCAL_C_INCLUDES := $(LOCAL_PATH)/../include/boost-1_49 \
# EDIT: replaced previous line from this, at Igor's correction: $(LOCAL_PATH)/../include/boost-1_49/boost \
                    $(LOCAL_PATH)/../include/boost-1_49/boost/archive \
                    $(LOCAL_PATH)/../include/boost-1_49/boost/serialization

LOCAL_MODULE:= boost_serialization
LOCAL_SRC_FILES:= ../lib/libboost_serialization-gcc-mt-1_49.a
LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/boost-build-includes
include $(PREBUILT_STATIC_LIBRARY)

android项目makefile,proj.android/jni/Android.m:

LOCAL_PATH := $(call my-dir)

include $(CLEAR_VARS)

LDFLAGS= -L$(NDK_ROOT)/sources/crystax/libs/armeabi-v7a/4.6.3 -Lcrystax 

LOCAL_CPPFLAGS += -fexceptions 

LOCAL_CPPFLAGS += -frtti

LOCAL_MODULE := game_shared

LOCAL_MODULE_FILENAME := libgame

LOCAL_SRC_FILES := hellocpp/main.cpp \
                   ../../Classes/AppDelegate.cpp \
                   ../../Classes/HelloWorldScene.cpp \
        ../../Classes/TitleScene.cpp \
        ../../Classes/GameSettings.cpp \
        ../../Classes/Cutscene.cpp \
        ../../Classes/HighScoreTable.cpp \
        ../../Classes/MaskNode.cpp \
        ../../Classes/MenuResponder.cpp \
        ../../Classes/HudElementBg.cpp \
        ../../Classes/OHRCharSelectMenu.cpp \
        ../../Classes/OHRDifficultySelectMenu.cpp \
        ../../Classes/Types.cpp \
        ../../Classes/OHRMainMenu.cpp

# I've tried with / without this variable, as well, with the same result
LOCAL_C_INCLUDES := $(LOCAL_PATH)/../../Classes \
$(LOCAL_PATH)/../include/boost-1_49 \
# EDIT: replaced previous line from this, at Igor's correction: $(LOCAL_PATH)/../include/boost-1_49/boost \
        $(LOCAL_PATH)/../boost/include/boost-1_49/boost/archive \
        $(LOCAL_PATH)/../boost/include/boost-1_49/boost/serialization

LOCAL_WHOLE_STATIC_LIBRARIES := boost_serialization cocos2dx_static cocosdenshion_static cocos_extension_static

include $(BUILD_SHARED_LIBRARY)

$(call import-module,CocosDenshion/android) \
$(call import-module,boost-build) \
$(call import-module,cocos2dx)

现在,当我运行ndk-build来编译我的源代码时,我收到以下错误:

Compile++ thumb  : game_shared <= main.cpp
Compile++ thumb  : game_shared <= AppDelegate.cpp
In file included from jni/../../Classes/MapUtils.h:2:0,
                 from jni/../../Classes/Types.h:3,
                 from jni/../../Classes/menuresponder.h:2,
                 from jni/../../Classes/OHRMainMenu.h:2,
                 from jni/../../Classes/TitleScene.h:10,
                 from jni/../../Classes/AppDelegate.cpp:6:

jni/../../Classes/BoostUtils.h:2:36: fatal error: boost/archive/tmpdir.hpp: No such file or directory

(BoostUtils.h是一个标题,只包含一堆与序列化相关的标题)

#include <boost/archive/tmpdir.hpp>

#include <boost/archive/text_iarchive.hpp>
#include <boost/archive/text_oarchive.hpp>

#include <boost/serialization/base_object.hpp>
#include <boost/serialization/utility.hpp>
#include <boost/serialization/list.hpp>
#include <boost/serialization/vector.hpp>
#include <boost/serialization/assume_abstract.hpp>

现在,今晚正好运行一次,在proj.android/obj/local中生成了一堆.so和.a,包括libbost_serialization.so。尽管删除了/ obj目录,但我还是无法生成它。同样奇怪的是,尽管本帖子顶部的链接建议,但是在运行ndk-build时没有创建/ libs目录。但是,我并不是100%确定。甚至需要生成。

所以,对于我的生活,我无法在这里找出问题所在。任何解决方案或方向都会非常受欢迎。

1 个答案:

答案 0 :(得分:1)

获得的经验:LOCAL_C_INCLUDES实际上是一个必要的变量,并确保它指向正确的位置。就我而言,它只是一个错误的'../'并包含'boost /'的内容,而不是包含boost的目录。

(另外,睡得更多,而不是花几个小时看一眼这些问题。)