From matlab support (Jerry Yan):
1. If it’s already loaded, no way to unload yet. The ability to unload the generated interface library is not available in MATLAB now. There is no workaround other than restarting MATLAB.
2. To pass matrix as a parameter to the interface, a good option is using “calllib” function to pass a matrix. Please refer to the following links to get more information.
https://www.mathworks.com/matlabcentral/answers/93197-how-can-i-pass-a-matrix-to-a-function-in-a-dll-defined-with-a-double-header-in-matlab-7-10-r2010
https://www.mathworks.com/help/matlab/matlab_external/pass-arrays.html
3. I understand that you want to build all things directly from Visual Studio. However, there is no command line usage outside of MATLAB for “clibgen.buildInterface”.
---
Regarding the second question, just get a set of triplets using find() and pass it along with the dimensions (all wrapped in a nice structure).
I'm wondering if it won't be easier to write a swig python extension and call python. It will resolve 1 & 3 since the python interface is more mature.
Call User-Defined Python Module - MATLAB & Simulink - MathWorks Australia
https://au.mathworks.com/help/matlab/matlab_external/call-user-defined-custom-module.html
MATLAB to Python Data Type Mapping - MATLAB & Simulink - MathWorks Australia
https://au.mathworks.com/help/matlab/matlab_external/passing-data-to-python.html