0

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

img

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?

LambdaTheDev
  • 160
  • 1
  • 9
  • try to delete plugin meta file i think its works – amirhosein adlfar Jun 05 '21 at 05:20
  • No effects. As I said in question - I even deleted whole Plugins folder. – LambdaTheDev Jun 05 '21 at 18:20
  • are you mixing x64 and x86? Use https://github.com/lucasg/Dependencies to see dependencies. There is no such thing as no dependencies (runtime, etc.) – mfkl Jun 14 '21 at 07:00
  • @mfkl I did it as you said, I found 4 dependencies, 2 are missing - `libstdc++-6.dll` and `libgcc_s_seh-1.dll`. I googled those & found out that some people had same problem with those. I saw this: https://stackoverflow.com/questions/6404636/libstdc-6-dll-not-found and this: https://www.youtube.com/watch?v=ioTerFFdX1E, followed all steps, but... error still exist. Let me edit my question so you can see compiler options – LambdaTheDev Jun 18 '21 at 13:59

0 Answers0