Developed by NDK to compile the Android/C + + program

Source: Internet
Author: User

    • Installing the NDK

From Androna Web download, NDK, double-click Unzip to current folder. Recommend that you want to install in that folder and unzip to that folder, and the path of the folder do not have spaces, because the GCC compile time will be the space before and after two strings as two folders to treat.

    • Compiling manually using GCC

Using the GCC compiler requires the makefile file to be written and then compiled with the GCC make tool, and the contents of the makefile file are as follows:

1 ndk_root=c:/android-ndk-r10d2 toolchains_root=$ (ndk_root)/toolchains/arm-linux-androideabi-4.9/prebuilt/windows3 toolchains_prefix=$ (toolchains_root)/bin/arm-linux-androideabi4 toolchains_include=$ (toolchains_root)/lib/gcc/arm-linux-androideabi/4.9/include-fixed5 platform_root=$ (ndk_root)/platforms/android-21/arch-arm6 platform_include=$ (platform_root)/usr/include7 platform_lib=$ (platform_root)/usr/lib8 Module_name=hello9 Rm=delTen flags=-i$ (toolchains_include) One -i$ (platform_include) A -l$ (platform_lib) - -nostdlib - -LGCC the -bdynamic - -LC - objs=$ (module_name). O - $ (platform_lib)/CRTBEGIN_DYNAMIC.O + $ (platform_lib)/CRTEND_ANDROID.O -  + All : A $ (Toolchains_prefix)-GCC $ (FLAGS)-C $ (module_name). C-o $ (module_name). O at $ (Toolchains_prefix)-GCC $ (FLAGS) $ (OBJS)-O $ (module_name) - Clean : - $ (RM) *.O - Install: - ADB push $ (module_name)/data/local/tmp -adb shell chmod 755/data/local/tmp/$ (module_name)

Where the GCC make tool is located: \android-ndk-r10d\prebuilt\windows\bin, this directory needs to be added to the system or the temporary PATH environment variable, then hello.c the makefile file into a directory, turn on the virtual machine, and then execute the following command in turn:

Makemake install adb Shell/data/local/tmp/hello

You'll see the familiar "Hello World!!!" The output.

I and L in the makefile to remember to distinguish, I did not notice, the result is always error when compiling.

Developed by NDK to compile the Android/C + + program

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.