Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Turns out that the PATH manipulation in the Unity code doesn't work well (at all) with the
SetDllDirectory
static constructor I had added here. Thus, as suggested in OSVR/OSVR-Unity#19 (comment), I've switched to doingLoadLibrary
calls of the DLLs in dependency order. Further, I've moved that out of a static constructor and just into a plain static method, for optional calling if you want that added help in ensuring you can find the native libs.I can confirm that running the examples on a 64-bit machine (in 64-bit mode) works, and the assembly works when used with the Unity integration.
Caveats to my testing or design: I don't know if there's a way to only call the
LoadLibrary
code if it's required (in a static constructor, so it would be automatic in a more cautious way), or if Mono or other runtimes do a mapping so that a pinvoke ofLoadLibrary
makes something happen on non-Windows platforms thus making my inclusion oflib*.so
code worthwhile. Also, at the moment we're just basically "leaking" the library handles - just a one-time thing, though, automatically cleaned up at process exit, (if the static method is called again, additional loadlibrary calls just increase a per-process ref count, so no way it will leak more than 4 library handles), and I wouldn't really expect to be able to change the native DLLs out from under an app while it's running anyway.