Compilation and link Debugging for Android NDK Project

Source: Internet
Author: User

Prerequisites: JDK 6.0, Android SDK, NDK R9, and eclipsele4.2 development environment have been installed.

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

1. First create an empty Android project on eclipsele4.2, it doesn't matter, as long as it is an Android project is OK.



2. Install the NDK-developed plugin Com.android.ide.eclipse.ndk_23.0.2.1259578.jar



The previous version of Eclipse contains this plugin without having to manually install the plugin; the latest eclipse software does not contain the plugin and must be downloaded by itself Com.android.ide.eclipse.ndk_23.0.2.1259578.jar Plug

copy to eclipse\. Plugins folder, close the Eclipse software and then restart Eclipse, and then proceed to the instance that can occur.




3. Configure the path of the NDK

Eclipse main Menu Windows-Preferences Open the file path for example, configure Android NDK:




Then do the following:




Appear as shown below, click Finish .




When you click Done, you'll see the Android project, and you'll find more than 3 folders, as shown in:




4. Andriod NDK Code Writing

The development of the Android NDK is available in C or C + +, but when developing the NDK using C or C + +, you should use the functions provided by the standard library of C or C + +.



5. In the android.mk file and the application.mk file, you can add a library that the NDK programming needs to support, with specific information about the NDK-programmed Google Docs.



Android NDK programming can be used by the C + + library:


Support for adding libraries for C + +:



6. Debugging the Android NDK



compile the Android Project again and the error message will appear:



Press the action to mask the error, and then compile the program again without popping the error box.



The Android NDK debugging uses the GDB program, and the Android NDK debugging principle is to use the socket for communication, so there must be a client and server side, and Android Virtual Confidential open . To debug the Android NDK program you must also write your own debug debug.mk and connect.mk files, and copy the two files to the Android NDK project's file directory.

The server-side debug.mk file is written:

Client connect.mk files are written:


Open the CMD program and turn on the server for Android NDK debugging:


Debug server side, cannot shut down.

Then open a CMD program to turn on the Android NDK debug client:



Attention:

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

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

These two paths add environment variables and no errors occur.






Compilation and link Debugging for Android NDK Project

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.