How to use iMSTK in unity

Hello,

I encounter problem of using iMSTK in unity. My OS is ubuntu 22.04. I followed the steps described here, https://imstk.gitlab.io/ImstkREADME.html. After then, I adapted CMakeLists.txt by changing the line 80, where “Build iMSTK-C# wrapper code and lib” is set to ON. Finally, I successfully built iMSTK.

However, I got confused when trying to use iMSTK in unity. As following pic. shows: I searched iMSTK under the Package Manager, and then import this package. After importing iMSTK, I have iMSTK options in the menu bar in Unity.

Then, I try to add a cloth by clicking iMSTK/GameObject/Deformables/Cloth. It keeps outlogging error: DllNotFoundException. But dll is the dynamic lib in windows system and I copied all the .so files from the iMSTK build directory to the project directory under ProjectIMSTK/Assets.

.

I also tried to adjust iMSTK settings under menu File/Build Settings. I enabled Use Developer Mode as follow pic shows, and then clicking force install.

After doing all of this, the unity console not only outputted DllNotFoundException, but also the error " Assets/Imstk/Scripts/GeometryMap.cs error: CS0246 the type or namespace name Imstk could not be found" .

Due to these errors, I cannot use iMSTK in unity. Can you please help me to tackle these or give me correct steps of using iMSTK in unity.

Thanks a lot.

I want to start with that using Imstk-Unity on Linux is completely untested, while we run the imstk library build on Linux Continous Integration (CI) machines, the Unity wrapping has not been tested in Linux environments at all.

It looks like you’re missing the iMSTKSharp.so.

The wrapping process has multiple stages and outputs, in the first a C interface is built for all functions that have been requested for wrapping in the .i files. This compiles to iMSTKCWrapper.so. In a second step a set of C# classes is generated that accesses the C interface. These need to be compiled as well. When using Visual Studio this can be done via a project but under Linux you’ll have to do this manually, the instructions for compiling the .cs files are https://gitlab.kitware.com/iMSTK/iMSTK/-/tree/master/Source/Wrappers?ref_type=heads

The output should be a iMSTKSharp.so that you’ll need to add to the other files, this should move you one step forward

Thanks for your answer. I checked the build directory and did not find iMSTKSharp.so. I tried to build iMSTK C/C++ Wrappers by setting the option from off to on in CMakeLists.txt as following pic. shows.

After rebuilding iMSTK project, I still find iMSTKSharp.so nowhere. Could you pls give any advices?

Under linux the iMSTKSharp.so cannot be built via cmake, only a visual studio project is generated. As i mentioned above you will have to build that manually as described in the Readme Mono Section

Please note again that we are not supporting linux and iMSTK Unity, i will only be able to give you limited help here

Got it, thanks!