jni £¯ C for android ¼¼Êõ×ÜÀ¿
Android±àÒë»·¾³(1) - ±àÒëNative CµÄhelloworldÄ£¿é
Android±àÒë»·¾³±¾Éí±È½Ï¸´ÔÓ£¬ÇÒ²»ÏñÆÕͨµÄ±àÒë»·¾³£ºÖ»Óж¥²ãĿ¼Ï²ÅÓÐMakefileÎļþ£¬¶øÆäËûµÄÿ¸öcomponent¶¼Ê¹ÓÃͳһ±ê×¼µÄAndroid.mk. Android.mkÎļþ±¾ÉíÊDZȽϼòµ¥µÄ£¬²»¹ýËü²¢²»ÊÇÎÒÃÇÊìϤµÄMakefile£¬¶øÊǾ¹ýÁËAndroid×ÔÉí±àÒëϵͳµÄºÜ¶à´¦Àí£¬Òò´ËÒªÕæÕýÀíÇå³þÆäÖеÄÁªÏµ»¹±È½Ï¸´ÔÓ£¬²»¹ýÕâÖÖ·½Ê½µÄºÃ´¦ÔÚÓÚ£¬±àдһ¸öеÄAndroid.mkÀ´¸øAndroidÔö¼ÓÒ»¸öеÄComponent»á±È½Ï¼òµ¥¡£
±àÒëJava³ÌÐò¿ÉÒÔÖ±½Ó²ÉÓÃEclipseµÄ¼¯³É»·¾³À´Íê³É£¬ÕâÀï¾Í²»Öظ´ÁË¡£ÎÒÃÇÖ÷ÒªÕë¶ÔC/C++À´ËµÃ÷£¬ÏÂÃæͨ¹ýÒ»¸öСÀý×ÓÀ´ËµÃ÷£¬ÈçºÎÔÚAndroid ÖÐÔö¼ÓÒ»¸öC³ÌÐòµÄHello World£º
1. ÔÚ$(YOUR_ANDROID)/development Ŀ¼Ï´´½¨helloĿ¼£¬ÆäÖÐ$(YOUR_ANDROID)Ö¸AndroidÔ´´úÂëËùÔÚµÄĿ¼¡£
- # mkdir $(YOUR_ANDROID)/development/hello
2. ÔÚ$(YOUR_ANDROID)/development/hello/Ŀ¼±àдhello.cÎļþ£¬hello.cµÄÄÚÈݵ±È»¾ÍÊǾµäµÄHelloWorld³ÌÐò£º
#include <stdio.h>
int main()
{
printf("Hello World!\n");
return 0;
}
3. ÔÚ$(YOUR_ANDROID)/development/hello/Ŀ¼±àдAndroid.mkÎļþ¡£ÕâÊÇAndroid MakefileµÄ±ê×¼ÃüÃû£¬²»Òª¸ü¸Ä¡£Android.mkÎļþµÄ¸ñʽºÍÄÚÈÝ¿ÉÒԲο¼ÆäËûÒÑÓеÄAndroid.mkÎļþµÄд·¨£¬Õë¶Ôhelloworld³ÌÐòµÄAndroid.mkÎļþÄÚÈÝÈçÏ£º
LOCAL_PATH:= $(call my-dir)
include $(CLEAR_VARS)
LOCAL_SRC_FILES:= \
hello.c
LOCAL_MODULE := helloworld
include $(BUILD_EXECUTABLE)
×¢ÒâÉÏÃæLOCAL_SRC_FILESÓÃÀ´Ö¸¶¨Ô´Îļþ£»£¬LOCAL_MODULEÖ¸¶¨Òª±àÒëµÄÄ£¿éµÄÃû×Ö£¬ÏÂÒ»²½Öè±àÒëʱ¾ÍÒªÓõ½£»include $(BUILD_EXECUTABLE)±íʾҪ±àÒë³ÉÒ»¸ö¿ÉÖ´ÐÐÎļþ£¬Èç¹ûÏë±àÒë³É¶¯Ì¬¿âÔò¿ÉÓÃBUILD_SHARED_LIBRARY£¬ÕâЩ¿ÉÒÔÔÚ$(YOUR_ANDROID)/build/core/config.mk²éµ½¡£
4. »Øµ½AndroidÔ´´úÂ붥²ãĿ¼½øÐбàÒ룺
# cd $(YOUR_ANDROID) && make helloworld
×¢Òâmake helloworldÖеÄÄ¿±êÃûhelloworld¾ÍÊÇÉÏÃæAndroid.mkÎļþÖÐÓÉLOCAL_MODULEÖ¸¶¨µÄÄ£¿éÃû¡£±àÒë½á¹ûÈçÏ£º
target thumb C: helloworld <= development/hello/hello.c
target Executable: helloworld (out/target/product/generic/obj/EXECUTABLES/helloworld_intermediates/LINKED
Ïà¹ØÎĵµ£º
Boss˵£¬Òª¿´OpenGL£¬¿´ÁË¿ìÒ»¸öÔ£¬×ÜËã³öÁ˸öÏñÑùµÄ¶«Î÷£¬ÓÃCдÁ˸ö3DÃÔ¹¬£¬
ËäȻֻÓÐ350ÐÐ
´úÂ룬²»¹ý±ßѧ±ßд£¬×ã×ãдÁËÒ»ÖÜʱ¼ä£¬»¹ÊÇСÓгɾ͸еģ¬»î»î»î£¡
&n ......
Linux C + + Training
Syllabus
________________________________________
1, Linux Operating System
System Environment: Ubuntu GNU / Linux, RedHat Linux AS5,
FreeBSD
Course Requirements: proficient use of commonly used Linux
/ UNIX commands.
Time: 1 week.
______________________________ ......
ÀûÓÃJNI¼¼Êõ£¬¿ÉÒÔ×öµ½C/C++ÓëJavaÖ®¼äµÄÏ໥µ÷Óá£
1¡¢Javaµ÷ÓÃC/C++½Ó¿Ú
Õâ¸öÊÇJNI×î»ù±¾µÄÓ¦Óã¬JNIÓкܶàÕâ·½ÃæµÄÀý×Ó´úÂë¡£Ò»°ã°ÑC/C++д³É¶¯Ì¬Á´½Ó¿â£»ÔÚJava³ÌÐòÔÚLoadLibrary£¬ÀûÓÃnative½Ó¿Ú£¬¼´¿ÉÍê³Éµ÷Óá£
2¡¢C/C++»Øµ÷Java½Ó¿Ú
ÕâÖÖÓ÷¨£¬JNIµÄÀý×ӱȽÏÉÙ¡£Æäʵ£¬Ò²±È½Ï¼òµ¥£¬JNIÒ²ÌṩÁËÕâÑùµÄ½Ó¿Ú¡ ......
int main()
{
int a[] = {1,2,3,4,5};
int i;
int * p = a;
for (p = a + 4, i = 0; i < 5; i++) {
printf("%d ",p[-i]);
}
return 0;
}
......