How to Compile MATLAB C++ Math Library
How to Compile MATLAB C++ Math Library
by Munehiro NakazatoWho need this?
Manuals
The manuals are available from MathWorks.Example codes are available in
/usr/local/matlab6_R12/extern/examples/cppmath
To Begin
You need add specific library to your LD_LIBRARY_PATHSolaris:
/usr/local/matlab6_12/extern/lib/sol2
SGI 64 (such as guinan):
/usr/local/matlab5.3.1/extern/lib/sgi64
Example:
# setenv LD_LIBRARY_PATH "/usr/local/matlab6_12/extern/lib/sol2:$LD_LIBRARY_PATH"
Use MBUILD - the easiest way
The easiest way to compile the code is mbuild tool When you run mbuild for the first time, I recommend you to setup mbuild
# /usr/local/matlab6_R12/bin/mbuild -setup
Then,
# /usr/local/matlab6_R12/bin/mbuild ex1.cpp
That's it !! It's very easy, isn't it?
For Windows
mbuild is in[matlab]\bin\mbuild
, where [matlab] is the location of MATLAB instllation. Manual Compile
For some situation, mbuild may not work well. In this case, you have to manually compile as shown below. The order to specify libraries is important.For Solaris
As long as I know, MATLAB Math Library works only with Sun's C++ compilers (CC). It causes error with GNU C++ (g++)# CC -DSOL2 -DUNIX -DX11 -DNDEBUG -O3 +d ex1.cpp \
-I/usr/local/matlab6_R12/extern/include/cpp \
-I/usr/local/matlab6_R12/extern/include -L/usr/local/matlab6_R12/extern/lib/sol2 \
-lmatpp -lmmfile -lmatlb -lmat -lmx -lnsl -lm
For SGI 64 (guinan)
# CC -64 -LANG:bool -DCOMPILER_HAS_BOOL ex1.cpp \
-I/usr/local/matlab5.3.1/extern/include/cpp \
-I/usr/local/matlab5.3.1/extern/include \
-L/usr/local/matlab5.3.1/extern/lib/sgi64 \
-lmatpp -lmmfile -lmcc -lmatlb -lmat -lmx -lm
No comments:
Post a Comment