简体   繁体   English

在Android ndk中使用C.

[英]Use C with Android ndk

I am trying to develop a Android project that makes a simple call from Java code to native C code. 我正在尝试开发一个Android项目,它可以从Java代码到本机C代码进行简单的调用。 I refer this link for my guidance: http://mobile.tutsplus.com/tutorials/android/ndk-tutorial/ 我将此链接作为我的指导: http//mobile.tutsplus.com/tutorials/android/ndk-tutorial/

when I am compiling the native.c using 当我使用编译native.c时

:ndk-build

it shows: 表明:

ndk-build command not found

Could anyone give the reason for this? 任何人都可以说出这个原因吗?

thanks , 谢谢 ,

From your question description, i assume that your path is not set. 从您的问题描述中,我假设您的路径未设置。 You need to set your NDK path in your environment variable. 您需要在环境变量中设置NDK路径。

for more information you can visit following site. 有关更多信息,您可以访问以下网站。

From my part, I try to set the path by several ways: 从我的角度来看,我尝试通过几种方式设置路径:

  • complete the /etc/paths file with the ndk directory and restart the Mac 使用ndk目录完成/ etc / paths文件并重新启动Mac
  • use the shell command: export NDK_HOME=/Users/myself/directory1/directory2/android-ndk-r9 使用shell命令: export NDK_HOME=/Users/myself/directory1/directory2/android-ndk-r9
  • use the Eclipse menu: Eclipse > Preferences > Android > NDK 使用Eclipse菜单:Eclipse> Preferences> Android> NDK

However I always get the error message: "ndk-build command not found" 但是我总是收到错误消息:“找不到ndk-build命令”

Finally I solved the issue by setting the path directly in the Build command field of the C/C++ Build Properties dialog box: /Users/myself/directory1/directory2/android-ndk-r9/ndk-build I know it's not a proper solution but it works for me for now. 最后,我通过直接在C / C ++ Build Properties对话框的Build命令字段中设置路径来解决了这个问题: / Users / myself / directory1 / directory2 / android-ndk-r9 / ndk-build我知道这不是一个合适的解决方案但它现在对我有用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM