且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何使用 Eclipse 安装和构建 NDK?

更新时间:2023-11-16 21:21:28

我按照 Santhosh_pulliman 提到的链接中给出的步骤操作,得到了输出.这可能会对您有所帮助.

I followed the Steps given in the link mentioned by Santhosh_pulliman and I got the output. This may help you.

第 1 步:在 eclipse 中安装 C/C++ 支持这将使您能够在 eclipse 中执行 c 语言程序.如果这安装完成,然后就可以看到c/c++项目选项了在创建新项目时.

Step 1 : Installation of C / C++ support in eclipse This will enable you to do c language program in eclipse. If this Installation completed, then you will be able to see the c / c++ project option while creating new project.

第 2 步:安装 Cygwin由于您在 ubuntu 10.10 中工作,因此您不需要此步骤.所以你会可以使用终端.

Step 2 : Installing Cygwin This step is not needed for you as you are working in ubuntu 10.10. So you will be able to use the terminal.

第 3 步:安装 Android ndk下载ndk并将其放在您拥有android sdk的文件夹中.

Step 3 : Installing Android ndk Download the ndk and put it in the folder where you have you android sdk.

第 4 步:创建一个新的 android 项目并在该文件夹中创建一个名为 jni 的新文件夹添加链接中给出的make文件和.c文件.

Step 4 : Create a new android project and create a new folder named jni and in that folder add the make file and .c file as given in the link.

第 5 步:打开终端,使用 cd 命令导航到您的项目目录.

Step 5 : Open the terminal, navigate to your project directory by using cd command.

     cd /path of your workspace/project name 

现在从项目文件位置执行 ndk-build 命令.

Now from the project file location execute the ndk-build command.

/your ndk path/android-ndk-r4/ndk-build

这将为您提供 .so 文件,这意味着已生成库文件.

This will give you .so file which means the library file is generated.

如果您在此处遇到错误,则安装和其他步骤将出现错误.

If you are getting error here then the installation and other step will be having error.

第 6 步:最后一步是创建您的 java 文件.

Step 6 : Final step is creating your java file.

现在您可以运行该应用程序了.你会得到输出

Now you can run the application. you will get the output