我試着在我的項目中使用std :: function,在這裏和那裏讀到C++ 11得到很好的支持。然而,簡單地使用std :: function會導致構建失敗:Android NDK和功能(std :: function)支持
[armeabi] Compile++ thumb: MyAppNative <= MyAppNative.cpp
jni/MyAppNative.cpp: In function 'jint JNI_OnLoad(JavaVM*, void*)':
jni/MyAppNative.cpp:7:2: error: 'function' is not a member of 'std'
std::function<void()> func;
^
jni/MyAppNative.cpp:7:24: error: 'func' was not declared in this scope
std::function<void()> func;
^
make: *** [obj/local/armeabi/objs/MyAppNative/MyAppNative.o] Error 1
我的問題是:is std :: function應該被支持嗎?我已經看到它有條件地定義在標題中,具體取決於_STLP_USE_BOOST_SUPPORT。這是正常的嗎?如果有人對測試感興趣,我附上了一個示例項目。
http://www.filedropper.com/cpp11-functional-issue
乾杯
您在構建時添加了-std = C++ 11'標誌嗎?哪個版本的GCC被使用? –
請參閱http://developer.android.com/ndk/guides/cpp-support.html上的「如何設置您的運行時間」。 –
是的,我確實添加了標誌(可以查看存檔),我認爲GCC版本是4.8(至少在更新到r10e進行測試之前)。 Christian>謝謝,但是std :: function在這裏沒有提及。我正在使用APP_STL:= stlport_static(在我的可下載示例中),並且沒有任何內容表示此版本已降級。 – Brunni