"Invalid MEX-file" when using curve fitting toolbox compiled
Show older comments
I use mbuild and mcc in a Makefile to compile some matlab functions into one shared lib and some wrapper code (C) into another shared lib. I've now added a function that uses 'fit' and it compiles, but I get this error message when it is called:
Error using fit>iFit (line 414)
Invalid MEX-file
'/usr/local/MATLAB/R2011b/toolbox/compiler/mcr/matlab/sparfun/etree.mexa64':
libmwarpack.so: cannot open shared object file: No such file or directory
Error in fit (line 109)
No amount of trying to explicitly chuck in the kitchen sink in the Makefile ultimately resolves this (e.g. explicitly adding -lmwarpack results in another error, tackle that and you get another). I resorted to trying to compile using deploytool and that can't find the runtime when you try to call it. I'd really prefer to use the Makefile route. Searching for help has come up with the closest match that this error means the toolbox (MEX file) was compiled using a different version of matlab. But I don't get how that can be. Toolbox is version 3.2. I get an error both using 2010bSP1 and 2011b.
Answers (1)
Kaustubha Govind
on 29 Nov 2011
0 votes
The issue is related to runtime, so it seems like more of a path issue, than a compile/link-time issue. Did you say that deploytool fails at compilation? If yes, perhaps the issue is with your MATLAB installation? Are you able to execute the MATLAB code from the MATLAB prompt? Also, please verify if the library exists in /usr/local/MATLAB/R2011b/bin/glnxa64. Does it also exist in the corresponding folder under the MCR installation root on the deployment machine?
2 Comments
Guy
on 30 Nov 2011
Kaustubha Govind
on 30 Nov 2011
Guy: I think you are confusing shared libraries (.so files) with the import libraries needed by DLLs on Windows. Shared libraries are not required at link-time at all, they are only needed at runtime where they are loaded using dlopen). So adding them to the makefile does not help anything. The only thing that is needed is that the MCR library path be added to the system path. See http://www.mathworks.com/help/toolbox/compiler/bqrw460-1.html#bqrw5ck-2 for path settings needed by deployed applications (matlabroot must be replaced with mcrroot where MCR is installed).
Typically, this path is updated automatically by the MCR installer on the deployment machine, but sometimes it may fail to do so (especially if it does not have administrative privileges).
Categories
Find more on C Shared Library Integration in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!