2013-01-16 52 views
0

我一直在試圖提振鏈接到我的以下說明Android應用程序:升壓的Android,NDK建造不創建的.so /頭無法找到

Include Boost C++ library in android

這似乎相當簡潔明智。不幸的是,經過幾天的努力,我看不出我做錯了什麼,因爲最終的結果是,ndk-build返回「沒有這樣的文件或目錄」關於我試圖包含的boost頭文件。

在構建我需要的boost庫之後,我將它們複製到了proj.android/jni/boost/include和proj.android/jni/boost/lib。然後我在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) 

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) 

現在,當我運行NDK建造編譯我的源代碼,我得到以下錯誤:

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> 

現在,今晚恰好有一次,運行這個程序會產生一堆.so和.a,包括proj.android/obj/local中的libbost_serialization.so。因爲儘管刪除了/ obj目錄,我仍然無法獲得它。另外奇怪的是,儘管這篇文章頂部的鏈接建議了,但在運行ndk-build時沒有創建/ libs目錄。但是,我不是100%肯定的,甚至需要生成。

因此,對於我的生活,我無法在這裏發現問題。任何解決方案或方向將非常感激。

+0

您包含路徑似乎是不正確的。它應該指向升級安裝的根目錄:$(LOCAL_PATH)/../include/blank_1_49/ –

+0

好的!這不是唯一需要的編輯,但它讓我尋找正確的問題。除了你的更正之外,jni /中的Android.mk,當包含boost頭文件時,我也會進入父目錄。謝謝! –

回答

1

獲得的經驗:LOCAL_C_INCLUDES實際上是一個必要的變量,並確保它指向正確的位置。就我而言,這只是一個錯誤的'../',並且包含'boost /'的內容,而不是包含boost的目錄。

(此外,睡眠更多,而不是花幾個小時看一眼這些問題。)

相關問題