使用任意 PATH 环境安装 MathLink 程序 [英] Install MathLink program with arbitrary PATH environment

查看:18
本文介绍了使用任意 PATH 环境安装 MathLink 程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以使用 Install[] 来启动带有自定义 PATH 环境变量的 MathLink 程序?

Is it possible to use Install[] to start a MathLink program with a custom PATH environment variable?

我正在尝试使用 mEngine 进行连接Mathematica 到 Windows 上的 MATLAB.它仅在 PATH 环境变量包含 MATLAB 库的路径时启动 mEngine.exe 才有效.是否可以修改 PATH 来启动这个程序,而不需要修改系统路径?或者还有其他方法可以启动 mEngine.exe?

I am trying to use mEngine to connect Mathematica to MATLAB on Windows. It only works if mEngine.exe is launched when the PATH environment variable includes the path to the MATLAB libraries. Is it possible to modify the PATH for launching this program only, without needing to modify the system path? Or is there another way to launch mEngine.exe?

推荐答案

@acl 的解决方案将 mEngine.exe 包装在一个批处理文件中,并从那里临时修改 PATH,工作正常:

@acl's solution to wrap mEngine.exe in a batch file, and temporarily modify the PATH from there, works correctly:

我用这个作为mEngine.bat的内容:

set PATH=c:path	omatlabinwin32;%PATH%
start mEngine.exe %*

  • *% 确保所有命令行参数都传递给 mEngine.exe
  • start 是防止命令窗口在 mEngine.exe 终止之前保持打开状态所必需的
    • *% ensures that all command line arguments are passed on to mEngine.exe
    • start is necessary to prevent the command window from staying open until mEngine.exe terminates
    • 可以使用Install["mEngine.bat"]来启动.

      由于内核与 mEngine.exe 通信所需的所有信息都由 Install[] 作为命令行参数传递,所以我们需要做的就是使用这些参数启动 mEngine.exe.Install[] 没有必要知道 mEngine.exe 的位置,重要的是使用正确的命令行参数启动进程,这是确保通过 %*.

      Since all the information that is needed for the kernel to communicate with mEngine.exe is passed by Install[] as command line arguments, all we need to do is launch mEngine.exe with these arguments. It is not necessary for Install[] to know the location of mEngine.exe, the important thing is that the process gets launched with the correct command line arguments, which is ensured by %*.

      这篇关于使用任意 PATH 环境安装 MathLink 程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆