Eclipse NDK Environment Building

Source: Internet
Author: User

Objective

Using the latest NDK, directly discard Cygwin, previously done Android projects to use the NDK will have to download the installation of Cygwin (simulated Linux environment), download the CDT (Eclipse C + + development plug-in), download the NDK, Also to configure the compiler, environment variables, especially troublesome, the new version is not required.


Tools

NDK, official because of the wall of bad reason open, in http://www.androiddevtools.cn/download


Configuration

1. System NDK environment variable configuration

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M02/6D/07/wKiom1VaFMLRyySnAAVykFSBOoU405.jpg "title=" Env.png "alt=" Wkiom1vafmlryysnaavykfsboou405.jpg "/>


2.Eclipse Configuration Ndk

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M01/6D/01/wKioL1VaFoSjk4UJAAJWqggQrQI666.jpg "title=" Eclipse Ndk.png "alt=" Wkiol1vafosjk4ujaajwqggqrqi666.jpg "/>


3.Eclipse Configuration Javah tool automatically generates JNI header files

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M01/6D/07/wKiom1VaFXPxJPVRAARSceJQDM4450.jpg "title=" 1.png " alt= "Wkiom1vafxpxjpvraarscejqdm4450.jpg"/>

#工作空间 ${project_loc} #工具执行参数-v-classpath ${project_loc}/bin/classes-d ${project_loc}/jni-jni ${java_type_name}

When using the Java file containing the native method, run Javah to generate the corresponding JNI header file in the JNI directory


4. new project with JNI

Create a new Android project, right-click Add native Support, will generate ANDROID.MK files and CPP files in the project directory

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M02/6D/01/wKioL1VaF2PBUNCoAAHYxMegd8c136.jpg "title=" 3.png " alt= "Wkiol1vaf2pbuncoaahyxmegd8c136.jpg"/>


5. Configure C, CPP header files and Ndk-build tools

Right-click Project--->properties

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M02/6D/07/wKiom1VaFmCxAhDOAAQdKVVn4eQ899.jpg "title=" 5.png " alt= "Wkiom1vafmcxahdoaaqdkvvn4eq899.jpg"/>


Add environment variable Ndkroot, the value of the NDK root directory

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M00/6D/01/wKioL1VaF--Rw5GQAAQmvbLHnU0179.jpg "title=" 6.png " alt= "Wkiol1vaf--rw5gqaaqmvblhnu0179.jpg"/>


650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M00/6D/07/wKiom1VaFoaDfDgUAASJF8egWa0576.jpg "title=" 7.png " alt= "Wkiom1vafoadfdguaasjf8egwa0576.jpg"/>


6.Log Information Printing

If there is a source environment, copy the System/core/inclue/cutils directory copy to {ndk-dir}/platforms/android- xx /arch-arm/usr/include

Copy out/target/product/ tcc893x /system/lib/libcutils.so, libutils.so to {ndk-dir}/platforms/android-xx/arch-arm/usr/lib

Add in Android.mk

local_shared_libraries:= libutils libcutils local_ldlibs: =-llog

then add the header file in the JNI cutils/log.h , you can use ALOGE/ALOGD/ALOGD


If you don't define yourself,

#include "android/log.h" static const char *tag= "Serial_port"; #define Logi (FMT, args ...) __android_log_print (android_ Log_info, Tag, FMT, # #args) #define LOGD (FMT, args ...) __android_log_print (android_log_debug, Tag, FMT, # #args) #define LO GE (FMT, args ...) __android_log_print (Android_log_error, TAG, FMT, # #args)



The above is about the Eclipse NDK build, quite simple, after the completion of the direct operation will automatically compile the JNI native code.

This article is from the "D.c_look" blog, make sure to keep this source http://doublewen.blog.51cto.com/3097132/1652624

Eclipse NDK Environment Building

Related Article

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.