IL2CPP missing native dll referenced by managed library

I have a NET dll that needs a few other (native) dlls in a subfolder in the same spot. They are all set to be included in the build, and are there, just not with the subfolder

In 2017.4 i have to manually copy them to a new subfolder in the managed folder, then everything works.

Now in 2018 and il2cpp i dont know where to put them.

Not sure if i already missed something in 2017, but i set all dlls to be included (x64 only)

in the editor everything works fine ( both 2017 and 2018)

In case it help - the library in question is the Embree.NET wrapper around the Intel Embree raytracing library

EDIT:
they are in the Plugins folder, but the library requires them to be in a “x64” subfolder, and however i try i cant seem to get it to work …

the net library searches for the dlls like this:

string fullPath = System.Reflection.Assembly.GetAssembly(typeof(RTC)).Location;
string assebmlyDirectory = Path.GetDirectoryName(fullPath);
string architecture = IntPtr.Size == 8 ? "x64" : "x86";
string dllDirectory = Path.Combine(assebmlyDirectory, architecture);
// Temporarily change working directory and make a call to Embree native code
// to force the dll to load
string previousCurrentDirectory = Directory.GetCurrentDirectory();
Directory.SetCurrentDirectory(dllDirectory);

So it seems to look for a x64 folder relative to the current dll - that worked in 2017, but how to fix this in 2018?

I don’t think that anything has changed with respect to IL2CPP between 2017.4 and 2018.1 regarding this case. However, something might be different in Unity that is causing this issue. What error message do you see in 2018.1 which indicates this does not work?

there is no error message - i just compiled the embree wrapper as is, and whatever exceptions it may encounter - i dont get any errors.
But something changed between 2017 and 2018 - threr is no managed folder where i can put my dlls…

What is the observable difference between Unity versions? Maybe that will help determine the cause of the issue?

I think there is a misunderstanding - try to clarify:

2017.4 : Compile with mono - the build has a folder named ‘Managed’ - there are the Net Dlls. here i put my native dlls manually (after the build) inside a new ‘x64’ folder, so my managed embree dll can find them. It cant find them in the plugins - i guess because of the code in the fist post.

2018.1: Compile with IL2CPP - there is no managed folder anymore. I dont know where to put my native dlls for embree. It cant find them in the plugins folder (as before).

the observable difference is that i dont get any image - so to speak… and i guess it is because my embree.dll (managed) cant find the native dlls to initialize. The program does not crash.

Ok, that makes more sense.

For Mono, the managed assemblies are delivered to the player and just-in-time (JIT) compiled on the device running the player. So your embree dll worked like that.

For IL2CPP, the managed assemblies are (ahead-of-time) AOT compiled on the machine running the Unity editor, and are never delivered to the device.

Rather than manually putting the files in the Managed directory, you can use the Managed Plugin process: Unity - Manual: Managed plug-ins

Then they should get AOT compiled by IL2CPP.

1 Like

cool will try that - thanks!