如何使用ndk-build.cmd构建Android.so文件
How to build the Android .so file using ndk-build.cmd
在尝试为Unity构建本机c++插件时获取DllNotFoundException。
FirstDll.cpp
#include "FirstDll.h"
DLLExport int add(int a, int b){
return a+b;
}
FirstDll::FirstDll(){
}
FirstDll::~FirstDll(){
}
FirstDll.h
#define DLLExport __declspec(dllexport)
extern "C"{
DLLExport int add(int a, int b);
}
class FirstDll{
public:
FirstDll();
~FirstDll();
};
然后我通过这个命令生成一个so文件
g++ -dynamiclib -flat_namespace -fms-extensions FirstDll.cpp -o libmyclass.so
然后我在Assets/Plugins/x86_64文件夹中添加了这个.so文件,在我的unity c#代码中,我正在尝试运行这段代码。
[DllImport("myclass")]
static extern int add(int a, int b);
在收到这个错误后,我尝试将so文件移动到不同的位置并进行测试。我总是收到DllNotFoundException。
Found that the DllNotFoundException was coming bcoz the .so file
is not build using ndk-build.cmd.
Plz help me with the steps to build the .so file for android.
NDK文档包含有关如何为Android构建库的说明。安卓工作室并不是严格要求的,但它使它更容易。如果你不使用它,你必须手动安装NDK。
相关文章:
- 如何使用ndk-build.cmd构建Android.so文件
- 如何调试visual studio 2017生成的C++代码.android中的SO文件和其他第三方库
- 我可以在Embarcadero C 建造者中为Android(*.so)构建共享库
- 是否可以在SO库中公开C API以访问Android JAVA方法
- 编译 android .so 库在 Visual Studio 错误与 android ndk 15c __signbi
- Android Studio 项目中的 c++ 代码是否最终出现在 apk 文件中(除了 .so 文件)
- SO文件未在Android Studio中使用CMake生成
- 如何构建和安装 OpenCV+contrib .so 库 for Android
- Android NDK生成海量只有一个功能的.so文件
- 在Visual Studio 2017上编译适用于Android的SDL2应用程序时缺少 libBox2D.so
- Android本机运行时无法加载符号,即使它们实际上是在加载的.so文件中找到的
- 在 Android 的第二个项目中添加一个 .so 库
- 从.lib切换到.so后,Android应用程序崩溃
- Android Studio不包括apk中的.so库:
- 如何在Java Android Studio Project中使用.so共享库
- Android Studio NDK:无法加载库"libgnustl_shared.so"
- 使用Android NDK从.so文件调用Native函数
- 未找到Android中的本机OpenCV UnsatisfiedLinkError libopencv_java.so
- android studio NDK使用第三个库(.so)进行编译
- 我们如何知道特定cpp文件在哪个.so文件中?(在Android房间)