Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Matlab toolbox installation #195

Closed
tvdbogert opened this issue Apr 2, 2021 · 4 comments
Closed

Matlab toolbox installation #195

tvdbogert opened this issue Apr 2, 2021 · 4 comments

Comments

@tvdbogert
Copy link

Thanks for the ezc3d project! I can now load a 90-second C3D file into Matlab in less than 1 second. With the Opensim C3D tools it took about 4 minutes.

I managed to build and install the Matlab MEX binaries using CMake and Visual Studio, and they work fine.

So far, I am assuming that all required DLL files are in the C:/Program FIles/MATLAB/.../toolbox/ezc3d folder. If so, I can simply give that folder to someone else to install the toolbox. Have not tested that yet.

However, it would be better if the toolbox could be installed from within Matlab, using the Add-Ons manager. The ezc3d toolbox is known to the Add-Ons manager, but does not install a functional toolbox. It seems to install the development folder and source code in an Appdata folder. Instead, I think it should just install the binaries, DLLs, and test code in a C:/Program FIles/MATLAB/.../toolbox/ezc3d folder.

Can this be fixed?

@pariterre
Copy link
Member

Dear @tvdbogert
Sorry for the late answer!
I am glad ezc3d suits your need :)

So far, I am assuming that all required DLL files are in the C:/Program FIles/MATLAB/.../toolbox/ezc3d folder. If so, I can simply give that folder to someone else to install the toolbox. Have not tested that yet.

Assuming you did not change the Matlab_ezc3d_INSTALL_DIR during the CMake configuration, that is correct

However, it would be better if the toolbox could be installed from within Matlab, using the Add-Ons manager. The ezc3d toolbox is known to the Add-Ons manager, but does not install a functional toolbox. It seems to install the development folder and source code in an Appdata folder. Instead, I think it should just install the binaries, DLLs, and test code in a C:/Program FIles/MATLAB/.../toolbox/ezc3d folder.
Can this be fixed?

To my knowledge, there is unfortunately no easy way provided by Matlab to compile non-Matlab code. Ezc3d is primarily a C++ library with Python and Matlab bindings. Therefore, something like wheeling in Python must be available in order to help compilation. As stated, I am not aware of such a thing. Consequently, providing a compiled version of ezc3d implies to manually compile it for the supported platforms (Windows, Mac and Linux) and each of the supported Matlab version (that is >2018a), which is a total of 24 versions on possibly two different computers (PC and Mac), for each ezc3d release... This is highly time consuming, and I've decided, based on this discussion #177 and this one #24 not to go with providing binaries for Matlab.

That said, I am in the process of adding octave binaries in conda-forge. The octave binaries are supposed to be less efficient mex files, but at least they exist.. They can therefore be downloaded and installed easily, but still it requires to manually change the extension to be recognized by Matlab, and is only available for Linux and Mac, as octave is not distributed for Windows on conda-forge.

So the short answer is yes, it can be fixed, but at the price of a huge price of manual work which I am unfortunately not ready to pay...

@tvdbogert
Copy link
Author

That makes sense. It was easy enough for me to turn on the Matlab bindings in CMake and build them. This produced a Matlab toolbox folder, and I can confirm that I can give someone that folder and it worked correctly for them. So we have this working fine now.

If you're interested in additional feedback, read on...

Unfortunately, this no longer seems to work in the version I built today. The toolbox is split into two folders:

9>-- Installing: /ezc3d_matlab/ezc3dRead.lib
9>-- Installing: /ezc3d_matlab/ezc3dRead.mexw64
9>-- Installing: /ezc3d_matlab/ezc3dWrite.lib
9>-- Installing: /ezc3d_matlab/ezc3dWrite.mexw64
9>-- Installing: C:/Program Files/MATLAB/R2020a/toolbox/ezc3d_matlab/ezc3d.lib
9>-- Installing: C:/Program Files/MATLAB/R2020a/toolbox/ezc3d_matlab/ezc3d.dll
9>-- Installing: C:/Program Files/MATLAB/R2020a/toolbox/ezc3d_matlab/ezc3dNewParam.m

Note the first one is in C:/ which is not really a good place... When I combined the contents of the two folder, put it in my Matlab path, I got the error "invalid MEX file" which usually means that a dll is missing or not compatible. I have not dug deeper, I can use the previously built version.

Also it's better not to assume a specific MATLAB version to install the toolbox.

Why not put the toolbox binaries in the ezc3d-dev folder and instruct the user to put it in the Matlab path. That way, also I don't need to run Visual Studio as administrator.

@pariterre
Copy link
Member

Hi again!

9>-- Installing: /ezc3d_matlab/ezc3dRead.lib
9>-- Installing: /ezc3d_matlab/ezc3dRead.mexw64
9>-- Installing: /ezc3d_matlab/ezc3dWrite.lib
9>-- Installing: /ezc3d_matlab/ezc3dWrite.mexw64

This is weird, I may have broken something when I have done the Octave binder last week, I have a look in the moment! Everything is indeed supposed to install in the same folder...

When I combined the contents of the two folder, put it in my Matlab path, I got the error "invalid MEX file" which usually means that a dll is missing or not compatible. I have not dug deeper, I can use the previously built version.

This should however definitely works... I'll try to compile ezc3d for matlab on Windows.

Also it's better not to assume a specific MATLAB version to install the toolbox.

I am not sure what you mean. The Matlab version (and its folder) is not assumed but dynamically found by CMake.

Why not put the toolbox binaries in the ezc3d-dev folder and instruct the user to put it in the Matlab path. That way, also I don't need to run Visual Studio as administrator.

Originally, I was installing in the $MyDocuments$/MATLAB which is by default added to the path at load-time and does not require admin rights. However, the problem is being cross-platform... I figured that installing in toolbox would always work, whatever the OS. That said, as a user, in CMake if you change the Matlab_ezc3d_INSTALL_FOLDER key for the path of $MyDocuments$/MATLAB, it will install in this folder and therefore not require admin rights

I have a look a the problems on Windows installation and I come back to you quickly!

@pariterre
Copy link
Member

pariterre commented Apr 13, 2021

The problem

9>-- Installing: /ezc3d_matlab/ezc3dRead.lib
9>-- Installing: /ezc3d_matlab/ezc3dRead.mexw64
9>-- Installing: /ezc3d_matlab/ezc3dWrite.lib
9>-- Installing: /ezc3d_matlab/ezc3dWrite.mexw64

is now fixed, thanks to PR #198

Thanks for reporting :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants