Android NDK project compilation and link debugging

Source: Internet
Author: User

Android NDK project compilation and link debugging

Prerequisites: JDK 6.0, android SDK, NDK r9, and javassele4.2 development environments have been installed.

It is recommended to download Android integrated KIT development adt-bundle-windows-x86, and then download Android NDK can start Android NDK program programming.

1. First create an empty Android project on javassele4.2. It doesn't matter if it is an Android project.

 

 

2. Install the plug-in com. android. ide. eclipse. ndk_23.0.2.1259578.jar developed by NDK.

 

 

The previous Eclipse version includes this plug-in. You do not need to manually install this plug-in. The latest Eclipse software does not include this plug-in. You must download com. android. ide. eclipse. ndk_23.0.2.1259578.jar

Copy to the eclipse \ plugins folder, close the Eclipse software, restart Eclipse, and then perform operations on the instance.

 


 

3. Configure the NDK path

Main Menu of EclipseWindows->PreferencesOpen the file path, for example, configure Android NDK:

 


 

 

Perform the following operations:


 

 

As shown below, clickFinishYou can.


 

 

After you click Finish, observe the Android project and generate three more folders, as shown in:


 

 

4. Compiling Andriod NDK code

Android NDK can be developed in C or C ++, but when C or C ++ is used to develop NDK, the functions provided by the C or C ++ standard library should be used.

 

 

5. In the Android. mk file and Application. mk file, you can add the required libraries for NDK programming. For more information, see Google Documents for NDK programming.

 

 

C ++ library for Android NDK programming:

 

Support for adding a C ++ Library:


 

 

6. debugging Android NDK

 

 

If you compile the Android project again, the following error occurs:


 

Block the error according to the operation,Re-compile the programThe error prompt box will no longer pop up.

 

 

Android NDK debugging uses the GDB program, and Android NDK debugging uses socket for communication. Therefore, a client and a server must be provided and the Android virtual machine must be enabled. To debug the Android NDK program, you must also compile the debug. mk and connect. mk files and copy these two files to the file directory of the Android NDK project.

Compiling the debug. mk file on the server:

 

Write the client connect. mk file:

 

Open the cmd program and enable the Android NDK debugging server:


 

The debugging server cannot be disabled.

Open a cmd program to enable the Android NDK debugging client:


 

 

Note:

D: \ adt-bundle-windows-x86-20130219 \ android-ndk-r9 \ prebuilt \ android-arm \ gdbserver (debug symbol)

D: \ adt-bundle-windows-x86-20130219 \ android-ndk-r9 \ toolchains \ arm-linux-androideabi-4.8 \ prebuilt \ windows \ bin (GDB)

No errors will occur after the environment variables are added to these two paths.





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.