Android NDKã使ãåã«ç¥ã£ã¦ãããæ¹ãè¯ãã¡ã¢
å·çæç¹ã®Android NDK(r19)ã«ã¤ãã¦ã
ç¥ã£ã¦æªããæ¹è¯ãäº
JNIã®Cãã¤ã³ãã£ã³ã°ã¨C++ãã¤ã³ãã£ã³ã°ã¯ã¾ã£ããå¥ç©
APIã®ååã¯åãæå¥ã«C++çã§ãåå空éã¤ããã¦ç¡ãã£ããã§ããããã¡ãªC/C++対å¿ã¨è¨ãã¤ã¤å®ã¯Cã£ã¦ãããã¿ã¼ã³ãã¨æãããC++ãã¤ã³ãã£ã³ã°ã§ã¯ååã®APIã§ãã©ã¡ã¼ã¿ã¼ã®æ°ãéã£ããããã¤ã³ã¿ã¼ã®ãã¤ã³ã¿ã¼ããã¤ã³ã¿ã¼ã¨åç §ã«ãªã£ã¦ãã¦APIã使ã£ãã¦ã¼ã¶ã¼å®ç¾©é¨åã®ã³ã¼ããCã¨C++ã§ã¯å¤ããå¿ è¦ããããªã©è¨è¨ãããããã
JNIã¯è殺ã
JNIã®JAVAã¨Cã®åå空éã®çµåã«ã¼ã«ã馬鹿ãªã®ã§ã¦ã¼ã¶ã¼å®ç¾©ã§snake_caseã®ã·ã³ãã«ã使ãã¨æ»ã¬ããããAndroidã§å®è¡ãã¦ã©ã³ã¿ã¤ã ã¨ã©ã¼ãåºç¾ããã¾ã§åé¡ã¯é¡å¨åããªãã
ãã®åé¡ã«å¯¾ãsnakerã®ç§ã¯_ã®ä»£ããã«å¤§æåã®'X'ã使ãäºã«ããããå¾ãªãã£ããä¾ãã°`jni_is_bakuhatsu`ã¯`jniXisXbakuhatsu`ã¨ãã¦ä»£æ¿ãããæªå¤¢çã§ããã
ã³ã³ãã¤ã©ã¼ã¨ã¯ä½ã ã£ãã®ã
æªå®ç¾©ã®ã·ã³ãã«ããã£ã¦ãã³ã³ãã¤ã«ã¨ã©ã¼ã¨ãã¯ã¼ãã³ã°ã¨ãç¡ããAndroidã§å®è¡ãã¦ã©ã³ã¿ã¤ã ã¨ã©ã¼ãåºç¾ããã¾ã§typoããåãããªãã
æ¨æºã©ã¤ãã©ãªã¼ã¯éæ¨æº
C++ã®æ¨æºã©ã¤ãã©ãªã¼ãæ¨æºã§ã¯ä½¿ããªããï¼Application.mkã«APP_STLãæ示çã«å®ç¾©ããå¿ è¦ãããï¼
C++æ¨æºã©ã¤ãã©ãªã¼ã使ãçºã«ã¯jni/Application.mkï¼jni/Android.mkã§ãã¹æå®ãç¹æ®åãå¯è½ï¼ãä½ããAPP_STLã«stlport_staticãªããgnustl_staticãæ示çã«å®ç¾©ããªããã°ãªããªãã
ãããå®ç¾©ããªãã¨STLãããªãã®ã«<string>ãã使ããªãã
g++-4.4.3ã ããC++11ã®ä¸é¨æ©è½ã使ããã¨ãç¡ãã£ã
使ããg++ã¯4.4.3ãªã®ã§-std=c++0xãCXXFLAGSã«å®ç¾©ãããªã©ããã°C++11ãªæ©è½ãä¸é¨ä½¿ããã
ãããã-std=c++0xããã¨<string>ãã³ã³ãã¤ã«ã¨ã©ã¼åãã®ã§std::stringã¨ä½µç¨åºæ¥ãªããstlport_static使ç¨ã§ãgnustl_static使ç¨ã§ãä½ãã«ããçºçããã
è£è¶³çãªäº
ãããarchãªã
archlinuxãªãAURã«android-sdkãandroid-ndkãããã±ã¼ã¸ãã¡ã³ãããã¦ãã
eclipseã¨ãå ¨ãå¿ è¦ç¡ãã
ã³ãã³ã群ï¼android ndk-build ant adb ddms ãªã©ï¼ã使ãã°è¯ãã
ãããä½æ ãadbã³ãã³ãã§uninstallã¨ãã¾ãæåããªãããAndroidç´æ¥æä½ãã¦ã¢ã³ã¤ã³ã¹ãã¼ã«ãã¦ããinstallãããªã©å¦ãªçããã£ããã¯ãã
ã§ã£ã¦ããï¼
ref
ãã®å¾ãAndroid NDKã使ããã¨ãã¦ããå¦çãããããã°ã§refã£ã¦ããã¦ãï¼ç»åä»ãã®è§£èª¬ãã¦ããã¦ãã®ã§åèã«ã