- Home /
DllNotFoundException while using unity native c++ Plugins
Getting DllNotFoundException when trying to build a native c++ plugin for Unity.
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(); };
I am then generating a so file via this command
g++ -dynamiclib -flat_namespace -fms-extensions FirstDll.cpp -o libmyclass.so
I am then added this .so file in Assets/Plugins/x86_64 folder and in my unity c# code, I am trying to run this piece of code.
[DllImport("myclass")] static extern int add(int a, int b);
After getting this error, I have tried to moved the so file to different locations and test. I am always getting DllNotFoundException.