1
\$\begingroup\$

Just a quick theoretical question so I don't hit a landmine further down development. In my current project, I have quite a lot of dll's that I made myself for use in Unity. If I were to develop for Android, would these dll's still function or is there another library format that Unity prefers to use? Basically, I'm looking for a rundown of all the ways you have to import libraries into Unity for use on a specific platform. For example,

1.) .dll files. Can you use them on other platforms?

2.) If not, how would I have to recompile code to allow me to access it the same way I currently do on a different plaform?

\$\endgroup\$
1
\$\begingroup\$

DLLs are Microsoft's implementation of the idea of a "shared library." You can only use them on platforms that, in some fashion, implement support for them.

In general, this means that no, you can't just take the DLL files you have and use them on Android, or on a macOS installation, or whatever.

Now, things like .NET and Mono are capable of reading PE files (the format of DLLs) and executing any managed code contained therein, so if your DLLs are, specifically, managed (which sounds like a possibility given what you've said about using Unity), they'll work on any platform that the appropriate version of Mono would work. Provided you don't call into any OS-specific or platform-specific stuff in them, et cetera. So there's a possibility, but it really depends on what you've written in those DLLs. You'll probably just need to test it and see.

If the DLLs are built from native code, however, you'll have to recompile them for the new target platforms into formats appropriate for those platforms. The specifics of doing so depend on the code you've written and the platforms you want to additionally target. It may simply be a matter of using the right compiler, but it may also involve writing interop stubs or something similar.

| improve this answer | |
\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.