我有一个用代码块编写的名为 main.cpp 的 cpp 文件。我想在 windows 10 64bit 中为 android 编译它。
#include <iostream>
#include <cmath>
using namespace std;
#define greater(x,y) (x<y?y:x);
int main(){
int a,b;
cout<<"Enter two numbers "<<endl;
cin>>a>>b;
cout<< "The greater number is "<<greater(a,b);
}
我使用适用于 windows 的 android ndk 工具链。我打开 cmd 并使用了这个命令。
x86_64-linux-android-gcc.exe main.cpp -o main.
我面临的错误..
fatal error: iostream: No such file or directory
#include <iostream>
^
compilation terminated.
我想我做错了程序。
编辑: 我找到了答案。
来源:http://tricksfairbd.blogspot.com/2018/05/compile-cpp-code-for-android-in-windows.html
最佳答案
您必须告诉 gradle
包含必需的库,以便可以使用它们进行编译。
在 build.gradle
中,您应该包含类似于以下内容的内容:
android.ndk {
moduleName = "hello-jni"
stl = "stlport_static"
}
关于android - 在 Windows 中为 Android 编译 .cpp 文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50573546/