开发者

(Mac,Matlab,bash) Changing the PATH of bash in Matlab for system commands

Hello Fellow Matlab Users,

I was wondering if anyone could provide me with some insight on how to change the bash path environment in Matlab.

Basically, if I start a given application in the terminal outside of Matlab everything works fine. (e.g.: 3dMean) However, if I try it in Matlab with the system command (system('~/abin/3dMean') (as you can see I have to tell Matlab where it is located) I get the following error:

dyld: Library not loaded: /usr/X11/lib/libpng12.0.dylib
  Referenced from: /Users/kjio/abin/3dMean
  Reason: Incompatible library version: 3dMean requires version 42.0.0 or later, but libpng12.0.dylib provides version 40.0.0
~/abin/3dMean: Trace/breakpoint trap

So I checked the bash PATH in Matlab, this is the output:

system('echo $PATH')

/usr/bin:/bin:/usr/sbin:/sbin

I tried to call the application with the following command:

system('env PATH=~/abin LD_LIBRARY_PATH=/usr/X11/lib 3dMean')

but that also doesn't work. I get the same error message.

Next what I tried was to change the PATH:

setenv('PATH', [TEMP; getenv('PATH') ]);

In the variable TEMP were all the paths of interest out of the Terminal $PATH. Now I could do that

system('3dMean')

But I get still the same error message.

开发者_高级运维

Is there any way to update the maci64 env or how can I change the bash PATH in Matlab to overcome this problem ??

Thanks


It looks like Matlab is linking against a different PNG library than when you run 3dMean from the command line. You probably want to change the DYLD_LIBRARY_PATH within matlab (not LD_LIBRARY_PATH) to point to a newer version of libpng


I would like to present step to step as to setting the PATH, DYLD_LIBRARY_PATH and other system variables in Matlab for CUDA on Mac (since this is what I am working on)

PATH = getenv('PATH');
setenv('PATH',[PATH ':/Developer/NVIDIA/CUDA-6.0/bin']);  

libpath = getenv('DYLD_LIBRARY_PATH');
setenv('DYLD_LIBRARY_PATH',[libpath ':/Developer/NVIDIA/CUDA-6.0/lib']);

besides, the ':' before '/Developer' is very important its function is to add a PATH instead of appending a string to the last path in the variable

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜