简体   繁体   English

Boost Android,ndk-build不会创建.so /头文件

[英]Boost Android, ndk-build doesn't create .so / headers can't be found

I've been trying to link boost into my android application following these instructions: 我一直在尝试按照以下说明将boost链接到我的android应用程序:

Include Boost C++ library in android 在Android中包含Boost C ++库

which seems to be pretty concise and sensible. 这似乎非常简洁和明智。 Unfortunately, after days of trying I can't see what I'm doing wrong, as the end result is that ndk-build returns "No such file or Directory" regarding the boost headers I try to include. 不幸的是,经过数天的尝试,我看不到自己在做错什么,因为最终结果是ndk-build返回有关我尝试包含的boost标头的“无此类文件或目录”。

After building the boost libraries I needed, I copied them in proj.android/jni/boost/include and proj.android/jni/boost/lib. 构建所需的Boost库之后,我将它们复制到proj.android/jni/boost/include和proj.android/jni/boost/lib中。 I then created a directory in jni called boost-build, where I created an Android.mk to handle define the module to link to the libboost_serialization static library (which is the only boost library I'm interested in). 然后,我在jni中创建了一个名为boost-build的目录,在其中创建了一个Android.mk来处理定义模块以链接到libboost_serialization静态库(这是我唯一感兴趣的boost库)。

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)

The android project makefile, proj.android/jni/Android.m: android项目的生成文件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)

Now, when I run ndk-build to compile my source, I get the following error: 现在,当我运行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 being a header that simply includes a bunch of serialization-related headers) (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>

Now, exactly once tonight, running this generated a bunch of .so's and .a's, include libbost_serialization.so, in proj.android/obj/local. 现在,今晚恰好运行一次,生成了一系列.so和.a,包括libbost_serialization.so,位于proj.android/obj/local中。 I have not been able to get that to be generated since, despite deleting the /obj directory. 从那以后,尽管删除了/ obj目录,但我一直无法生成该文件。 Also odd is that, despite what's suggested by the link at the top of this post, a /libs directory is not being created when ndk-build is run. 同样奇怪的是,尽管这篇文章顶部的链接提出了建议,但是运行ndk-build时并没有创建/ libs目录。 However, I'm not 100% sure that .so even needs to be generated. 但是,我不是100%确定.so甚至需要生成。

So, for the life of me I can't identify the problem here. 因此,对于我的一生,我无法在此处找到问题所在。 Any solutions or direction would be much, much appreciated. 任何解决方案或方向将不胜感激。

Lesson learned: LOCAL_C_INCLUDES actually is a necessary variable, and make sure it's pointing to the right place. 经验教训:LOCAL_C_INCLUDES实际上是一个必需的变量,并确保它指向正确的位置。 In my case, it was just an errant '../' and including the contents of 'boost/', rather than the directory containing boost. 在我的情况下,它只是一个错误的“ ../”,包括“ boost /”的内容,而不是包含boost的目录。

(Also, sleep more, rather than spend hours glancing over these issues.) (另外,多睡些,而不要花几个小时浏览这些问题。)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM