svenberra / NewtonUnityPlugin

NewtonUnityPlugin is a managed plugin for Unity 3D that allows you to use the Newton Dynamics physics engine
MIT License
50 stars 10 forks source link

DLL Not Found - Exception Thrown in NewtonWrapperPINVOKE+SWIGExceptionHelper:: #14

Open xemjeff opened 5 years ago

xemjeff commented 5 years ago

I have built Newton Dyanmics and the NewtonUnityPlugin in visual studio 2019. No errors on build in either project.

When I try to load the project: demo_04_StandardJoints in Unity (v 2017.3.1f), I get this error.

DllNotFoundException: NewtonWrapper
NewtonWrapperPINVOKE+SWIGExceptionHelper..cctor ()
Rethrow as TypeInitializationException: An exception was thrown by the type initializer for SWIGExceptionHelper
NewtonWrapperPINVOKE..cctor ()
Rethrow as TypeInitializationException: An exception was thrown by the type initializer for NewtonWrapperPINVOKE
dNewtonWorld..ctor ()
NewtonWorld..ctor ()
xemjeff commented 5 years ago

Solution to this problem.

Using DependencyWalker, I found that the NewtonWrapper plugin could not load because the following dlls were missing (for debug):

dContainers_d.dll
dCustomJoints_d.dll
newton_d.dll

After copying these from the NewtonDynamics project to the Demos/Assets/Plugins folder, the NewtonUnityPlugin Demos.sln, loaded into Unity, now works.

The longer term solution to this problem is to fix the post build steps in the visual studio solution to copy the right files, I noticed that the xcopy commands fails as well, trying to copy the file to the wrong folder. This is probably because I regenerate the visual studio solution from cmake into a build folder rather than use the old VS2015 project.

svenberra commented 5 years ago

Those dlls shouldn't be needed if Newton is compiled as a static lib as is done when using this solution... sdk\projects\visualStudio_2015_static_mt\build.sln. However you mentioned using cmake instead and that explains it.

CharlesQHappy commented 4 years ago

@xemjeff Have you "swig" the "newton.i" file to generate the wrap file for c++ and c# ? I stuck here, the wrap file is missing. error1 error2

Do you know how does this happen?