简体   繁体   English

如何在android-ndk项目中使用C ++类

[英]How to use C++ classes in android-ndk project

people! 人! I am looking for an example or any advice, of how to use C++ classes in android-ndk project. 我正在寻找一个例子或任何建议,如何在android-ndk项目中使用C ++类。 There are a lot of examples, but they all written in pure C. And there are a lot of topics where people asking the same question. 有很多例子,但它们都是用纯粹的C语言编写的。而且有很多话题都是人们提出同样的问题。 But there are stupid answers, or people who answering don't know that C and C++ are different languages ))) I have been searched a lot, I've also been on the 10th search page of google search ), but nothing found ) So, how to use C++ classes in android-ndk project? 但是有愚蠢的答案,或回答的人不知道C和C ++是不同的语言)))我已经搜索了很多,我也一直在谷歌搜索的第10个搜索页面,但没有找到)那么,如何在android-ndk项目中使用C ++类? Please give an example like famous "hello world". 请举例说明着名的“你好世界”。

Problem is when I am including *.h file with class ndkclass { }; 问题是当我包含带有类ndkclass {}的* .h文件时; defined into it, I have got this error: expected '=', ',', ';', 'asm' or ' attribute ' before 'ndkclass' 定义到它,我有这个错误:在'ndkclass'之前预期'=',',',';','asm'或' attribute '

Does your file has .cpp extension? 你的文件是否具有.cpp扩展名? If it has .c extension then compiler thinks your code is C, not C++, and that's why you will get error message. 如果它有.c扩展名,那么编译器会认为你的代码是C而不是C ++,这就是为什么你会得到错误信息。

Using C++ in android-ndk is same as in any other place (Visual C++, XCode, GCC, ...) 在android-ndk中使用C ++与在任何其他地方使用C ++(Visual C ++,XCode,GCC,...)

以下是如何使用android中的opencv c ++类的说明: http//opencv.itseez.com/doc/tutorials/introduction/android_binary_package/android_binary_package_using_with_NDK.html#android-binary-package-with-ndk您将样本检查为很高兴看到一些有用的例子。

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

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