I am doing some simple native code for Unity and I have found myself in trouble.
My native DLL structure is:
Sources\
- src\
- AddClass.cpp
- main.cpp
Headers\
- includes\
- AddClass.h
- main.h
In main.cpp I instantiate new AddClass object & execute one method in it, everything is pure C++ without any depencencies.
I compiled it into DLL, put in the Assets/Plugins
folder & tested it. Everything was working properly.
Then, I took a break, shut down my PC and came back after some time & started Unity again and - DllNotFoundException.
I enabled LoadOnStartup, and this is message I received:
Plugins: Failed to load 'Assets/Plugins/TestCPPToCS.dll' because one or more of its dependencies could not be loaded.
But as I said - I use no dependencies in that DLL.
Note 1
I tried following thing:
- Deleted Plugins folder (while Unity was on)
- Waited until Unity recompiles project
- Shut down Unity
- Start it again
- Again, created Plugins folder & put there DLL
Still I got the DllNotFoundException. If this is any useful, I use the 2019.4.28f1
version.
Note 2
I wanted to check if it will work in the new Unity project. Same situation - at the first time everything works, after restart - DllNotFound.
Note 3
I used the dependency walker alternative & found out that I have some missing dependencies. Those are:
- libstdc++-6.dll
- libgcc_s_seh-1.dll
I googled those and saw that some other people had similar problems. I took a look at following resources:
And I followed all steps mentioned in SO post & YT video. Here are my Code-Blocks compiler settings
Note 4
I have exactly the same problem with my "regular" C# application -> So, if possible, avoid Unity-only solutions and provide... more stable solution?