"Error while obtaining sizes from MEX S-function"
5 views (last 30 days)
Show older comments
Hi,
So, I had a working mex file ".mexw32" on a different system (windows XP, 32 bit, MATLAB 32.bit, compiled with Visual C++ 2008 Express). I am trying to get it to work in another system (windows 7, 64 bit, MATLAB 2011b 32bit, Visual C++ 2010 Express), but I cant get it to work. It compiles without an error ( everything in 32 bit) but when I ran my simulation, Matlab crashes with the following error :
" Warning: Error while obtaining sizes from MEX S-function 'openSimSFunction' in 'contact_shapes/S-Function1'. In general\private\openmdl at 13 In open at 159 In contact_shapes_runsimulation at 18 Warning: FatalException In general\private\openmdl at 13 In open at 159 In contact_shapes_runsimulation at 18 Model Loaded.!!!!!! Number of controls 0. Number of Actuators = 0
------------------------------------------------------------------------ Segmentation violation detected at Fri Mar 29 15:40:51 2013 ------------------------------------------------------------------------ "
I spend a lot of time reading the Mathworks Central, I know it is caused by the missing .dll's. I used dependency walkers and found out some dll's are missing.
(GPSVC.DLL
IESHIMS.DLL
LIBMEX.DLL
LIBMX.DLL)
The last two seems to be the matlab dll's which I checked and they exist on my path using the "!echo %PATH%" command. I have no idea why it says they are missing. The other two seems to be the VC++ dll's. I even downloaded the latest SDK.
Here is how I compile my code:
" % Define the mex code to be compiled mexcode = ' openSimSFunction.cpp';
% Define the OpenSim libraries libs=[' "' opensimroot '\sdk\lib\osimTools.lib"'... ' "' opensimroot '\sdk\lib\osimSimulation.lib"'... ' "' opensimroot '\sdk\lib\osimCommon.lib"'... ' "' opensimroot '\sdk\lib\osimAnalyses.lib"'... ' "' opensimroot '\sdk\lib\osimActuators.lib"'... ' "' opensimroot '\sdk\lib\xerces-c_2.lib"'... ' "' opensimroot '\sdk\lib\OpenSim_SimTKcommon.lib"'... ' "' opensimroot '\sdk\lib\OpenSim_SimTKsimbody.lib"'... ' "' opensimroot '\sdk\lib\OpenSim_SimTKmath.lib"'... ' "' opensimroot '\sdk\lib\SimTKlapack.lib"'];
% Include the OpenSim and Microsoft Visual studio 9.0 header files include = [' -I"' opensimroot '\sdk\include"'... ' -I"' opensimroot '\sdk\include\SimTK\include"'... ' -I"C:\Program Files (x86)\Microsoft SDKs\Windows\v7.1\Include"'... ' -I"C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include"'];
% Define compiler's Flag compilerFlags=[' -DWIN32'... ' -D_WINDOWS'... ' -D_CRT_SECURE_NO_DEPRECATE'];
% Compile and link source files into a shared library eval(['mex -v -f msvc100opts.bat' include compilerFlags mexcode libs])
"
*In the previous version I was using : "eval(['mex -v -f msvc90freeopts.bat' include compilerFlags mexcode libs]) "
to compile my code. Is this causing any problem.? I mean is there a difference between ( msvc90freeopts.bat and msvc100opts.bat) *
I really appreciate if I can get your insight on this issue.
I even tried to debug my code by attach it in to Visual C++, but it just crash before even starting and I am sure it is not a problem with my C++ code, because it was working on my other system.
Thank you and I really appreciate your comments.
1 Comment
Kaustubha Govind
on 1 Apr 2013
How is 'contact_shapes_runsimulation' related to the MEX-file? The error from the MEX-file seems to point to this file?
Answers (0)
See Also
Categories
Find more on C Shared Library Integration in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!