Mex-file Error When Code Called From Web Server

Hi all,
I have written a program that uses PHP to call a background Matlab procedure.
For an example, the procedure is very simple:
function [ h ] = testProc( )
out='starting'
X=[2 3 4; 3 4 5;]
Y = pdist(X, 'spearman' )
out='ran'
h=0;
end
which is compiled using mcc:
mcc -m testProc.m
I can call this program from the command line and it runs just fine:
./run_testProc.sh /usr/local/MATLAB/R2011a/
But when I wrap it in some PHP and call it from the web page:
$cmd='./run_testProc.sh /usr/local/MATLAB/R2011a/';
$output=shell_exec($cmd);
It initially starts running, but then crashes when it hits the pdist function, presumably because it's not seeing the libraries correctly. From the logs this is the error:
??? Invalid MEX-file
'/tmp/.mcrCache7.15/testPr0/toolbox/stats/stats/private/pdistmex.mexglx':
/tmp/.mcrCache7.15/testPr0/toolbox/stats/stats/private/pdistmex.mexglx: failed
to map segment from shared object: Operation not permitted
Error in ==> pdist at 273
Error in ==> testProc at 5
MATLAB:invalidMEXFile
I'm assuming this is some sort of permissions issue with the install. My Unix admin skills aren't very good but our systems administrator has been trying help, yet we are still stuck.
Any insight at all would be appreciated.
Thank you!!!
Michele

Answers (1)

See if this solution helps.

1 Comment

Good start, but one can't simply copy around the mcr cache. One needs the MCR_CACHE_ROOT environment variable to specify the extraction path of the ctf content:
http://www.mathworks.com/help/releases/R2012a/toolbox/compiler/brl4_f1-1.html

Sign in to comment.

Categories

Asked:

on 27 Apr 2012

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!