MATLAB: Mex libraries for accessing matlab code from C++

cMATLAB C/C++ Math Librarymex -setupmex compiler

Hi Matlab experts,
I am new to the forum, so any help will be highly appreciated. I am using a C++ code, which calls functions from Matlab, using the engine:
#include "engine.h"
and uses Engine *ep, to call functions like: mxCreateDoubleMatrix(), engPutVariable(), etc., and computes a cholesky decomposition: engEvalString(ep, "U=chol(T);");.
The C++ code I am working on is from 2002, and uses Matlab R13, Linux version. It accesses the following libraries from the Makefile:
INCLUDE= -I/apps/common/matlab/R13/Linux/extern/include
LIBS= -L/apps/common/matlab/R13/Linux/extern/lib/glnx86 -lmx -lut -lmat -leng
The problem is that when I try to use a newer version of Matlab, such as 2009a on an Ubuntu machine, the libraries -lmx -lut -lmat -leng are no longer existent. Currently, without these, I get these errors (I do include the "engine.h" file):
./src/monte.cpp: In member function ‘bool CMonte::CalChol(Engine*, double*, std::vector<EleDecomp, std::allocator<EleDecomp> >*&)’:
./src/monte.cpp:346: error: ‘mxSetName’ was not declared in this scope
./src/monte.cpp:349: error: ‘memcpy’ was not declared in this scope
Please let me know if anyone has some experience with this. It will be highly helpful for me. Thanks,
Saket Gupta

Best Answer

Saket,
Those libraries still exist, but they would be at a different location in R2009a:
  • The INCLUDE directory will likely be at a place like /usr/local/matlab/R2009a/extern/include.
  • The LIBS directory will likely be at a place like /usr/local/matlab/R2009a/bin/glnxa64 (64-bit bit), or glnx86 (32-bit)
if you run MEX from within MATLAB with the -v switch, it will spit out verbose information, including the directory paths you need to specify with -I and -L