I've been struggling for some time with a problem regarding the mex compilation of the fortran functions under the rnt directory of the RNT toolbox.
For some reason, matlab can't find the libsvml.so dynamic library, although the LD_LIBRARY_PATH is set correctly, pointing to the directory where the library is. I have always thought that matlab inherits the environment variables of the shell from where it was invoked, but this time it couldn't find the library. Every time I tried to call the rnt_oa2d_mex matlab function, matlab issued the error:
Code: Select all
??? Invalid MEX-file '/home/cesga/mcobas/RNT/matlib/rnt/rnt_oa2d_mex.mexa64':
/home/cesga/mcobas/RNT/matlib/rnt/rnt_oa2d_mex.mexa64: undefined symbol: __svml_exp2.
Error in ==> rnt_oa2d at 80
[t2,t2err]=rnt_oa2d_mex(lonr,latr,t1,lon,lat,pmap,a,b);
I tried workarounds in several webs, like (http://www.linux-forum.de/gel-st-compil ... 14040.html, http://software.intel.com/en-us/forums/ ... hp?t=60482 or [url]ttp://software.intel.com/en-us/forums/showthread.php?t=62218[/url], to mention a few, but no success. Matlab kept giving me the same error.
In the end, I had to compile against the static library, libsvml.a, located on the same directory. You can do this "by hand", copying and pasting the command that matlab uses. If you type
Code: Select all
mex -v rnt_oa2d_mex.f
Code: Select all
ifort -c -I/opt/cesga/matlabR2008b/extern/include -I/opt/cesga/matlabR2008b/simulink/include -fexceptions -fPIC -fno-omit-frame-pointer -DMX_COMPAT_32 -O3 "rnt_oa2d_mex.f"
Code: Select all
ifort -O3 -pthread -shared -Wl,--version-script,/opt/cesga/matlabR2008b/extern/lib/glnxa64/fexport.map -Wl,--no-undefined -o "rnt_oa2d_mex.mexa64" rnt_oa2d_mex.o "/opt/cesga/matlabR2008b/extern/lib/glnxa64/version4.o" -Wl,-rpath-link,/opt/cesga/matlabR2008b/bin/glnxa64 -L/opt/cesga/matlabR2008b/bin/glnxa64 -lsvml -lifcoremt -lmx -lmex -lmat -lm
if you add
Code: Select all
-static-intel /absolute/path/to/the/library/libsvml.a
You can go to the rnt directory and compile and link each "_mex.f" individually, but perhaps it is better to include these options in the file "mexopts.sh", located under the $HOME/.matlab directory. This is how my mexopts.sh file looks like now. I changed the section glnxa64.
Code: Select all
FC='ifort'
FFLAGS='-fexceptions'
FFLAGS="$FFLAGS -fPIC -fno-omit-frame-pointer"
FLIBS="$RPATH $MLIBS -lm"
FOPTIMFLAGS='-O3'
FDEBUGFLAGS='-g'
#
LD="$COMPILER"
LDEXTENSION='.mexa64'
LDFLAGS="-pthread -shared -Wl,--version-script,$TMW_ROOT/extern/lib/$Arch/$MAPFILE -Wl,--no-undefined -static-intel /opt/cesga/intel/Compiler/11.0/083/lib/intel64/libsvml.a"
LDOPTIMFLAGS='-O3'
LDDEBUGFLAGS='-g'
#
POSTLINK_CMDS=':'
Code: Select all
MLIBS="-L$TMW_ROOT/bin/$Arch -lifcoremt -lmx -lmex -lmat"
Code: Select all
ldd rnt_oa2d_mex.mexa64
I know this is not the best solution, but it is the best I could find. I'm just posting it in case someone comes across the same problem, and in case someone can find a better solution.
Kind regards,
Marcos Cobas Garcia
Centro de Supercomputacion de Galicia
A Coruna, Galicia, Spain