2016-03-23 19 views
0

アンドロイド用のChaiScriptライブラリを構築できません。
当初、私はそれが正常に動作しているAndroid用CMake GUIを使用してC++ 11でChaiScriptをコンパイルできない

Source Path + binary Path -> Configure -> Specify Generator -> Generate -> Make.  

述べたステップ以下のようにCMakeのGUIを使用してlinuxMintのために建てChaiScriptしようとしました。そう、私が述べたステップ

Source Path + binary Path -> Configure -> Specify Generator
1. Select specify tool-chain for cross compiling
2. (android.toolchain.cmake)
3. Path environment variable modified to have android-ndk path(added to .profile)
-> Generate -> Make.

以下のようにAndroidのためにそれを構築しようとした今ではとエラーが発生します「エラー: 『to_stringには、』 『STD』のメンバではありません」&「エラー: 『ストールは』ではありません"std"のメンバー

最初に私はこの標準:: to_stringとstd :: stollをeclipse + Android + NDKで使用するためにPOCを行い、"compile, build & run"にしました。 = C++ _静的

  • TARGET_PLATFORM::=アンドロイド-21
  • TARGET_ARCH_ABI:= armeabi-v7aしかし、ここでCMakeのGUIで私はどのように入力するには、以下のフラグ

    • APP_STL任意のアイデアを持っていません

    タイプとして「エントリの追加」と「文字列」を試しました。しかし、運がない。それでもエラーは存在します。任意の解決策/提案が高く評価されました。

  • 答えて

    0

    私自身が私の質問のためにこの解決策を投稿しています。 (私はEclipseの代わりにEclipse + Jniを使ってコードをコンパイルしたので、質問に適切な解決策はありません)。

    Eclipse IDE + Android Projectを使用してソースをコンパイルしました。 + JNIメソッド(Android NDK + Android.mk + Application.mk)。 stackoverflow QAの一部を参照することによって、以下のAndroid.mkとApplication.mkスクリプトが作成されました。スクリプト内では、コメントの中でフラグを使用する理由が示されました。これらのコメントは、スクリプトを理解するのに役立ちます。アンドロイドNDKの私のバージョンは、ファイルchaiscript_threading.hppに未定義マクロ "CHAISCRIPT_HAS_THREAD_LOCAL" に私が必要

    #undef CHAISCRIPT_HAS_THREAD_LOCAL (you can understand if you refer the source code) 
    
    thread_localストレージクラスをサポートしていないよう

    Android.mk

    LOCAL_PATH := $(call my-dir) 
    #Build Script to build ChaiScript library 
    include $(CLEAR_VARS) 
    #Used the below flag for (error: undefined reference to '__atomic_fetch_add_4') 
    LOCAL_LDLIBS += -latomic 
    # Here we give our module name and source file(s) 
    LOCAL_MODULE := chaiscript 
    #ChaiScript header files 
    LOCAL_C_INCLUDES := $(LOCAL_PATH)/include_CS 
    #ChaiScript source files 
    LOCAL_SRC_FILES := src_CS/chaiscript_stdlib.cpp src_CS/main.cpp src_CS/stl_extra.cpp src_CS/test_module.cpp 
    #CPP files in the extension 
    LOCAL_CPP_EXTENSION := .cxx .cpp .cc .hpp 
    include $(BUILD_SHARED_LIBRARY) 
    
    #Build Script to build library caller code  
    #LOCAL_PATH := $(call my-dir) #won't get cleared by clear_vars 
    include $(CLEAR_VARS) #clearing the variables defined for chaiscript build 
    LOCAL_MODULE := test_chaiscript 
    LOCAL_SRC_FILES := libchaiscript.so #can be 'chaiscript' alone 
    #ChaiScript Library headerfiles 
    LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/include_CS 
    #Caller code header files 
    LOCAL_C_INCLUDES := $(LOCAL_PATH)/header_own 
    #Caller code source files 
    LOCAL_SRC_FILES := src_own/NativeFunction.cpp src_own/clsArithmeticParser.cpp 
    include $(BUILD_SHARED_LIBRARY) 
    

    Application.mk

    #APP_STL := stlport_static 
    #Build the library by enabling C++11 
    APP_STL:=c++_static 
    APP_LDLIBS += -llog 
    #Used the below flag for 
    #(Error: '...' handler must be the last handler for its try block [-fpermissive] 
    #   } catch (const std::out_of_range &) {) 
    APP_CPPFLAGS += -fexceptions 
    #Used the below flag for (Error: 'dynamic_cast' not permitted with -fno-rtti) 
    APP_CPPFLAGS += -frtti 
    #Architecture to support armeabi-v7a & x86 
    APP_ABI := armeabi-v7a x86 
    #Android platform 
    APP_PLATFORM := android-21 
    

    ndk-build output :

    ndk-build 
    Android NDK: WARNING: APP_PLATFORM android-21 is larger than android:minSdkVersion 9 in ./AndroidManifest.xml  
    [armeabi-v7a] Compile++ thumb: chaiscript <= chaiscript_stdlib.cpp 
    [armeabi-v7a] Compile++ thumb: chaiscript <= main.cpp 
    [armeabi-v7a] Compile++ thumb: chaiscript <= stl_extra.cpp 
    [armeabi-v7a] Compile++ thumb: chaiscript <= test_module.cpp 
    [armeabi-v7a] SharedLibrary : libchaiscript.so 
    [armeabi-v7a] Install  : libchaiscript.so => libs/armeabi-v7a/libchaiscript.so 
    <i ignored the output of [x86] Compile++> 
    

    Code Usage :

    #include "header_own/NativeFunction.h" 
    #include "include_CS/chaiscript/chaiscript.hpp" 
    #include "include_CS/chaiscript/chaiscript_stdlib.hpp" 
    
    std::string str; 
    
    std::string helloWorld(const std::string &t_name) { 
        str = "Hello " + t_name + "!"; 
        return "Hello " + t_name + "!"; 
    } 
    
    JNIEXPORT jstring JNICALL Java_com_example_androidxmldesign_1exercise01_clsNativeFunctionWrapper_invokeNativeFunction(
         JNIEnv *env, jobject obj) { 
        chaiscript::ChaiScript chai(chaiscript::Std_Lib::library()); 
        chai.add(chaiscript::fun(&helloWorld), "helloWorld"); 
        chai.eval(R"(puts(helloWorld("Bob"));)"); 
        //below string return value will be appended to a textview 
        //existing vlaue 
        return env->NewStringUTF(str.c_str()); 
    } 
    

    Screen Shot : enter image description here

    +0

    これはおそらく、私はあなたが安全で、このスレッドであることをChaiScriptエンジン自体は必要ありません推測しているの#undef CHAISCRIPT_HAS_THREAD_LOCAL'がされる代わりに、 'のちょうど'の#define CHAISCRIPT_NO_THREADS'価値がありますパフォーマンスが大幅に向上します。 – lefticus

    +0

    @lefticus、それをチェックさせてください。 – Jeet

    関連する問題