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
回答(1 个)
Kaustubha Govind
2012-4-30
0 个投票
1 个评论
Friedrich
2012-4-30
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
类别
在 帮助中心 和 File Exchange 中查找有关 C Shared Library Integration 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!