Invalid MEX-File / Problem with shared (library) object
Show older comments
I want to use external libraries within a mex-file (from Willowgarage, libgazebo, the API of the robot simulator environment). The C++-code compiles (I am using the supported gcc version 4.4.6 of my R2012b Matlab distribution on a 64-bit Ubuntu 12.04 platform), but when I try to invoke the mexa64-file (which is recognized by Matlab), I got the following error:
Invalid MEX-file '/<local-folder>/Matlab/testGazeboMex.mexa64': libgazebo_transport.so.1: Can not open shared object file: No such file or directory
I added the path of the mentioned library (all other libraries are also in this place) to the LD_LIBRARY_PATH and PATH environment variable. I checked the dependencies using the !ldd command within Matlab, which seems fine. My code is just a test at the moment, if it compiles and initializes some objects:
#include <mex.h>
#include <stdio.h>
#include <string>
#include "gazebo.hh"
#include "Transport.hh"
#include "Node.hh"
#include "msgs.h"
using namespace std;
using namespace gazebo;
void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
{
gazebo::transport::init();
gazebo::transport::NodePtr node(new transport::Node());
}
1 Comment
Ferdinand
on 31 Oct 2012
Answers (1)
Kaustubha Govind
on 31 Oct 2012
0 votes
Is it possible that libgazebo_transport.so is a 32-bit library? Perhaps you should try using the file command as described here to determined this. Since you are compiling a 64-bit MEX-file, you can only link/load 64-bit shared libraries.
2 Comments
Ferdinand
on 31 Oct 2012
Kaustubha Govind
on 2 Nov 2012
Ferdinand: Strange. I don't know what else to suggest since you've already verified that !ldd confirms that all dependencies for the MEX-file are on the path. Perhaps you should contact MathWorks Tech Support?
Categories
Find more on Write C Functions Callable from MATLAB (MEX Files) 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!