Created
October 22, 2021 00:39
-
-
Save scivision/442f1cacad26bc087ff1d5af5a48bbaa to your computer and use it in GitHub Desktop.
Windows Octave using MinGW executables needs MinGW on PATH
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function prepend = mingw_octave_path() | |
% for Octave on Windows, it's necessary to prepend MinGW path | |
% when running MinGW-compiled executables | |
% Also, Matlab with Parallel Toolbox MPIEXEC conflicts with system MPIEXEC, | |
% so excise from Path | |
% | |
% a command is then run like | |
% | |
% system([prepend, ' ', 'foo.exe']) | |
prepend = ''; | |
if ~ispc, return, end | |
if isoctave && ~isempty(getenv('MINGWROOT')) | |
syspath = [getenv('MINGWROOT'), pathsep, getenv('PATH')]; | |
% setenv('PATH', syspath) % does not help | |
prepend = ['set PATH=', syspath, ' && ']; | |
else | |
addons = matlab.addons.installedAddons(); | |
if ~any(addons.Name == "Parallel Computing Toolbox") | |
return | |
end | |
path_orig = split(getenv('PATH'), ';'); | |
i = contains(path_orig, 'MATLAB'); % Matlab's MPIexec will fail | |
path_new = join(path_orig(~i), ';'); | |
% setenv('PATH', path_new{1}) % does not help | |
prepend = "set PATH=" + path_new{1} + " && "; | |
end % if | |
end % function |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment