android studio项目中CMake和NDK-build的区别 [英] Difference between CMake and NDK-build in android studio project

查看:29
本文介绍了android studio项目中CMake和NDK-build的区别的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

CMakeNDK 在 android studio 项目中构建的实际区别是什么.我已经浏览了谷歌文档,但概念尚不清楚.根据谷歌文档:

What is the actual difference between CMake and NDK build in android studio project. I already went through google documentation but the concept is not clear yet. As per google documentation:

Android 原生开发工具包 (NDK): 一个工具集,可让您在 Android 上使用 C 和 C++ 代码,并提供平台库允许您管理本机活动和访问物理设备组件,例如传感器和触摸输入.

The Android Native Development Kit (NDK): a toolset that allows you to use C and C++ code with Android, and provides platform libraries that allow you to manage native activities and access the physical device components, such as sensors and touch input.

CMake: 与 Gradle 一起构建的外部构建工具你的本地图书馆.如果您只是计划,则不需要此组件使用 ndk-build.

CMake: an external build tool that works alongside Gradle to build your native library. You do not need this component if you only plan to use ndk-build.

当我们需要使用什么时,谁能用一个例子更好地解释?

Can anyone has a better explanation with an example when we need to use what?

推荐答案

在这里澄清一些混淆:ndk-build 是包含在 NDK 中的构建系统.它使用 Android.mk 文件.NDK 本身是为 Android 构建 C/C++ 代码所需的编译器和库的集合.ndk-build 和 cmake 都使用 NDK.

To clear up some confusion here: ndk-build is a build system included in the NDK. It uses Android.mk files. The NDK itself is a collection of compilers and libraries that are needed to build C/C++ code for Android. ndk-build and cmake both use the NDK.

android studio 项目中 CMake 和 NDK 构建的实际区别是什么.

What is the actual difference between CMake and NDK build in android studio project.

他们使用不同的语言(自定义 makefile 与 cmake)来描述构建.理想情况下,相同描述的构建的输出没有差异,但这并不意味着没有任何错误.

They use a different language (custom makefiles vs cmake) to describe builds. Ideally there is no difference in output for identically described builds, but that doesn't mean there aren't any bugs.

当我们需要使用什么时,谁能用一个例子更好地解释?

Can anyone has a better explanation with an example when we need to use what?

一般来说,使用您喜欢的任何系统.

In general, use whichever system you prefer.

CMake 的主要优点是您可以为所有目标(Android、Linux、Windows、iOS 等)使用一组构建文件.如果您的项目是跨平台的,CMake 应该让您最轻松.它在 Android 开发者之外也广为人知,因此 Android 新手将有更好的机会了解它.

CMake's main advantage is that you can use one set of build files for all your targets (Android, Linux, Windows, iOS, etc). If your project is cross platform, CMake should make that easiest on you. It also is widely known outside Android developers, so people new to Android will have a better chance of understanding it.

如果您正在构建的项目已经将 Android.mk 文件用于其构建系统(遗留项目),则应该首选 ndk-build.

ndk-build should be preferred if you're building a project that already uses Android.mk files for its build system (legacy projects).

如果您正在编写新代码,请使用您喜欢的任何代码.如果您对两者都不熟悉,cmake 可能是更好的选择,因为如果您选择这样做,它将使将来跨平台工作更容易.

If you're writing new code, use whatever you're comfortable with. If you're not familiar with either, cmake is probably the better choice because it will make cross-platform work easier in the future if you choose to do so.

这篇关于android studio项目中CMake和NDK-build的区别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆