0

I am trying to import a third-party static library as a plugin into unity. I copied the library to Assets/Plugins/x64 folder and set the OS of the Plugin to Windows and architecture to x64. However, while it compiles the code fine, when I run the scene that uses the code from this static library, it complains DllNotFoundException: cspice assembly: type: member:(null). Can Unity import static libraries? I have this static library imported using the PINVOKE feature like this:

[DllImport("cspice")] public extern static void furnsh_c(string file);

I can confirm that the script for these PINVOKE statements and the static library (cspice.lib) are located in the same directory. Note that I don't have this issue with plugins that have a dynamic link library (DLL).

I would any suggestions/recommendations to get this working.

Thanks, Datri

5
  • See stackoverflow.com/questions/729562/… => you either need to compile a DLL or use managed C++ wrapper plugin .. though one answer also states To update the outdated answer. If using IL2CPP Scripting backend rather than Mono, it's now possible to link against static libs because IL2CPP uses ahead of time compilation while Mono uses Just in time compilation. are you using IL2CPP? Commented Nov 19, 2024 at 16:16
  • Yes, I am using IL2CPP. It does not seem to have an impact on the import of the static plugin. Commented Nov 19, 2024 at 17:19
  • Also, note that I have this error when running the scene, compilation of the scripts/scene is successful. Commented Nov 19, 2024 at 17:47
  • Have you tried to specify the entire relative path instead of "cspice"? like e.g. "./cspice.lib" or try a path relative to Assets .. alternatively also try __Internal .. Unity might be including the plugins directly .. tbh these are all just guesses, I'm not very deep into native plugins either. Here is a lot to read about that in more detail mono-project.com/docs/advanced/pinvoke (Mono specific) Commented Nov 20, 2024 at 8:06
  • Yes, I tried fullpath specification for the library in the DllImport clause. That does not work. How does one use __Internal spec? Commented Nov 20, 2024 at 14:08

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.