Plugin load in Matlab
- Romain LEBERRE
- Posts: 12
- Joined: Fri Feb 24, 2012 11:47 am
Plugin load in Matlab
Hi,
I am using a force defined by a plugin and I would like to load a model containing this force in Matlab.
Is-there any way to load the specified plugin library in Matlab?
Thanks for your help
Regards,
Romain
I am using a force defined by a plugin and I would like to load a model containing this force in Matlab.
Is-there any way to load the specified plugin library in Matlab?
Thanks for your help
Regards,
Romain
- Ayman Habib
- Posts: 2248
- Joined: Fri Apr 01, 2005 12:24 pm
Re: Plugin load in Matlab
Hi Romain,
Assuming you have the plugin as a shared library (dll) built with same compiler as OpenSim, then you need to ad the directory that contains it to the "librarypath" in Matlab, and then you can invoke loadlibrray() as documented on the Matlab side.
Hope this helps, and please let me know how it goes.
-Ayman
Assuming you have the plugin as a shared library (dll) built with same compiler as OpenSim, then you need to ad the directory that contains it to the "librarypath" in Matlab, and then you can invoke loadlibrray() as documented on the Matlab side.
Hope this helps, and please let me know how it goes.
-Ayman
- Romain LEBERRE
- Posts: 12
- Joined: Fri Feb 24, 2012 11:47 am
Re: Plugin load in Matlab
Thanks Ayman
- Brad Humphreys
- Posts: 79
- Joined: Thu Feb 03, 2011 11:32 am
Re: Plugin load in Matlab
I am trying to do this also: load a custom pluggin library in MATLAB.
I have:
1) Ensured that my mex -setup is:
Compiler: Microsoft Visual C++ 2010
Location: C:\Program Files (x86)\Microsoft Visual Studio 10.0
2) In MATLAB, I then use:
(I also know that the controller works in OpenSim. I am using 32bit MATLAB that works with built in OpenSim libraries.)
When I issue the above, I get the error:
I believe this is because loadlibrary is only meant for loading C, not C++.
How do I get custom libraries loaded into MATLAB?
Thanks!
Brad
I have:
1) Ensured that my mex -setup is:
Compiler: Microsoft Visual C++ 2010
Location: C:\Program Files (x86)\Microsoft Visual Studio 10.0
2) In MATLAB, I then use:
Code: Select all
fullpathToHeader = 'C:\OpenSimWorkspace\CustController\CustController.h';
fullpathToDll = 'C:\OpenSim 3.0.1\plugins\CustController.dll';
loadlibrary(fullpathToDll, fullpathToHeader);
When I issue the above, I get the error:
Code: Select all
Error using loadlibrary (line 419)
Failed to preprocess the input file.
Output from preprocessor is:HeroController.h
C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\INCLUDE\eh.h(27) : fatal error C1189: #error : "eh.h is only for C++!"
How do I get custom libraries loaded into MATLAB?
Thanks!
Brad
- Ayman Habib
- Posts: 2248
- Joined: Fri Apr 01, 2005 12:24 pm
Re: Plugin load in Matlab
Hi Brad,
It may help to know where is the "HeroController.h" file in the error message. Most likely issue:
Per MSDN: "Since eh.h is for exception handling it shouldn't be used in a program compiled as C".
Matlab claims to support mex files compiled as C++ so that should take care of the problem
Please let me know how that goes,
-Ayman
It may help to know where is the "HeroController.h" file in the error message. Most likely issue:
Per MSDN: "Since eh.h is for exception handling it shouldn't be used in a program compiled as C".
Matlab claims to support mex files compiled as C++ so that should take care of the problem
Please let me know how that goes,
-Ayman
- Brad Humphreys
- Posts: 79
- Joined: Thu Feb 03, 2011 11:32 am
Re: Plugin load in Matlab
Ayman,
My apologies, that was from me trying this with another custom controller. The message is in fact:
While MATLAB does allow for MEX of C++, the loadlibrary command only works for C (not C++). Do I need to recompile/mex the custom controller inside MATLAB instead of using the loadlibrary command?
Brad
My apologies, that was from me trying this with another custom controller. The message is in fact:
Code: Select all
Error using loadlibrary (line 419)
Failed to preprocess the input file.
Output from preprocessor is:CustController.h
C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\INCLUDE\eh.h(27) : fatal error C1189: #error : "eh.h is only for C++!"
Brad
- Dimitra Blana
- Posts: 17
- Joined: Thu Jul 24, 2008 11:59 am
Re: Plugin load in Matlab
Has this been solved? I'm having the same problem: I have built a plugin that works in Opensim but cannot load into Matlab with "loadlibrary" because I get the "eh.h is only for C++!" error (I'm using 32bit Matlab 2013b, Opensim 3.2, Visual Studio 2010).
Thank you!
Dimitra
Thank you!
Dimitra
- Xiangjie Meng
- Posts: 15
- Joined: Wed Sep 05, 2012 8:09 pm
Re: Plugin load in Matlab
Hi Dimitra,dimitra wrote:Has this been solved? I'm having the same problem: I have built a plugin that works in Opensim but cannot load into Matlab with "loadlibrary" because I get the "eh.h is only for C++!" error (I'm using 32bit Matlab 2013b, Opensim 3.2, Visual Studio 2010).
Thank you!
Dimitra
You should use the "osimPlginDLL.h" instead of the "eh.h" you mentioned when you use "loadlibrary()".
I have achieved this successfully.
Best,
Xiangjie
- Vinh Nguyen
- Posts: 21
- Joined: Fri Sep 26, 2014 8:53 pm
Re: Plugin load in Matlab
Could you explain more clearly? Is that related to matlab code or VS C++ code?You should use the "osimPlginDLL.h" instead of the "eh.h" you mentioned when you use "loadlibrary()"
Thanks,