Skip to content

Commit

Permalink
Windows: Move all Matlab mexw64 mex files into PsychBasic folder.
Browse files Browse the repository at this point in the history
The special PsychBasic/MatlabWindowsFilesR2007a subfolder is
obsolete since a long time, so get rid of it and store the Matlab
mex files for Windows in the same location as the Matlab mex files
for Linux and macOS - the PsychBasic/ folder. The file extension
makes sure everything gets sorted. This may make it possible to
reenable "Matlab Toolbox Add-On" MLTBX support in the future.

Adapt AssertMex() and PsychtoolboxPostInstallRoutine() accordingly.

Untested so far.
  • Loading branch information
kleinerm committed Jan 31, 2025
1 parent 4f9f5c4 commit 5cd3e14
Show file tree
Hide file tree
Showing 23 changed files with 17 additions and 65 deletions.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
37 changes: 8 additions & 29 deletions Psychtoolbox/PsychOneliners/AssertMex.m
Original file line number Diff line number Diff line change
Expand Up @@ -156,36 +156,15 @@
fprintf([' ' mexFilename '\n\n']);

if isempty(which(mexFilename))
if strcmp(computer, 'MAC')
% Mac PowerPC:
fprintf('Matlab running on MacOSX on a PowerPC based Apple Macintosh computer is no longer supported.\n');
fprintf('You would need to get a version 3.0.9 or earlier Psychtoolbox for this to work on your computer.\n');
fprintf('Or upgrade your computer to run a modern version of GNU/Linux and use the Psychtoolbox for Linux on PowerPC.\n\n');
elseif (IsWin && exist('mexext') && strcmp(mexext, 'dll')) %#ok<EXIST>
% Windows with Matlab pre-R2007a:
fprintf('Matlab versions older than V7.4 aka R2007a running on MS-Windows are no longer supported by this release.\n');
fprintf('Install GNU/Octave or a more modern Matlab version instead. Or downgrade to Psychtoolbox version 3.0.9 or earlier.\n\n');
else
fprintf('Hmm. I cannot find the file on your Matlab path?!?\n\n');
fprintf('One reason could be that your Matlab path is wrong or not up to date\n');
fprintf('for the current Psychtoolbox. You may want to run SetupPsychtoolbox to \n');
fprintf('fix possible path problems.\n\n');
end
fprintf('Hmm. I cannot find the file on your Matlab path?!?\n\n');
fprintf('One reason could be that your Matlab path is wrong or not up to date\n');
fprintf('for the current Psychtoolbox. You may want to run SetupPsychtoolbox to \n');
fprintf('fix possible path problems.\n\n');
else
if IsWin
fprintf('It is important that the folder which contains the Screen mex file is located *before*\n');
fprintf('the PsychBasic folder on your Matlab path.\n');
fprintf('On Matlab V7.4 (R2007a) or later versions, the folder\n');
fprintf('%sPsychBasic\\MatlabWindowsFilesR2007a\\ must be before the folder\n%sPsychBasic\\ \n\n', PsychtoolboxRoot, PsychtoolboxRoot);
fprintf('type path to display the current path and check for this condition.\nIf the order is wrong, ');
fprintf('simply cd into your Psychtoolbox root folder\n%s and then run SetupPsychtoolbox again.\n', PsychtoolboxRoot);
fprintf('That is the simplest way of fixing such path problems - Or to get more diagnostic output.\n\n');
end

if ~isequal(which(mexFilename), which(callerName))
fprintf('Seems %s.m is in the Matlab path before/above %s instead of after/below it!\n', callerName, mexFilename);
fprintf('This will cause the mex file to be ignored, leading to this error.\n');
fprintf('Please run SetupPsychtoolbox again, to rectify this problem, or use Matlabs pathtool\n');
fprintf('Please run SetupPsychtoolbox again to rectify this problem, or use Matlabs pathtool\n');
fprintf('to shuffle things into the right order. This folder:\n\n');
fprintf('%s\n', fileparts(which(mexFilename)));
fprintf('\nneeds to go above/before this folder:\n\n');
Expand All @@ -196,12 +175,12 @@
end

if IsWin
fprintf('On Microsoft Windows with supported Matlab versions (>= V7.4) it could also be that\n');
fprintf('the required Visual C++ 2015-2019 runtime libraries are missing on your system.\n');
fprintf('On Microsoft Windows with supported Matlab versions R2014b or later, it could also mean\n');
fprintf('that the required Visual C++ 2015-2019 runtime libraries are missing on your system.\n');
fprintf('The Psychtoolbox/PsychContributed/ subfolder contains installer files for them, which\n');
fprintf('you can execute after quitting Matlab. The name of the file is:\n');
if IsWin(1)
fprintf('vcredist_x64_2015-2019.exe and maybe also vcredist_x64_2010.exe.\n');
fprintf('vcredist_x64_2015-2019.exe - you maybe also additionally need vcredist_x64_2010.exe.\n');
else
fprintf('unknown - no longer ships with this version of Psychtoolbox.\n');
end
Expand Down
45 changes: 9 additions & 36 deletions Psychtoolbox/PsychtoolboxPostInstallRoutine.m
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,8 @@ function PsychtoolboxPostInstallRoutine(isUpdate, flavor)
% 11/24/2024 Call the 1st time setup routine PsychLicenseHandling() as
% needed to enable license management on Apple macOS and
% Microsoft Windows. (MK)
% 01/31/2025 Remove subfolder MatlabWindowsFilesR2007a for Matlab on Windows, and associated
% special path setup on Matlab for Windows. (MK)

fprintf('\n\nRunning post-install routine...\n\n');

Expand Down Expand Up @@ -551,49 +553,20 @@ function PsychtoolboxPostInstallRoutine(isUpdate, flavor)

% Special case handling for different Matlab releases on MS-Windoze:
if IsWin && ~IsOctave
rc = 0;

if strfind(cd, 'system32') %#ok<STRIFCND>
% the below code fails if the current directory is system32 (e.g.
% C:\Windows\system32), as it contains dlls like version.dll, which
% get called instead of the built-in functions....
cd(PsychtoolboxRoot);
end

try
% Remove DLL folders from path:
rmpath([PsychtoolboxRoot 'PsychBasic\MatlabWindowsFilesR2007a\']);

% Is this a Release2014b (Version 8.4.0) or later Matlab?
if verLessThan('matlab', '8.4.0')
% This is a pre-R2014b Matlab: No longer supported by V 3.0.18+
fprintf('Matlab release prior to R2014b detected. This version is no longer\n');
fprintf('supported by Psychtoolbox 3.0.18 and later. Aborted.');
fprintf('\n\nInstallation aborted. Fix the reported problem and retry.\n\n');
return;
else
% This is a R2014b or later Matlab:
% Add PsychBasic/MatlabWindowsFilesR2007a/ subfolder to Matlab path:
rdir = [PsychtoolboxRoot 'PsychBasic\MatlabWindowsFilesR2007a\'];
fprintf('Matlab release 2014b or later detected. Will prepend the following\n');
fprintf('folder to your Matlab path: %s ...\n', rdir);
addpath(rdir);
end

rc = savepath;
catch
rc = 2;
end

if rc > 0
fprintf('=====================================================================\n');
fprintf('ERROR: Failed to prepend folder %s to Matlab path!\n', rdir);
fprintf('ERROR: This will likely cause complete failure of PTB to work.\n');
fprintf('ERROR: Please fix the problem (maybe insufficient permissions?)\n');
fprintf('ERROR: If everything else fails, add this folder manually to the\n');
fprintf('ERROR: top of your Matlab path.\n');
fprintf('ERROR: Trying to continue but will likely fail soon.\n');
fprintf('=====================================================================\n\n');
% Is this a R2014b (Version 8.4.0) or later Matlab?
if verLessThan('matlab', '8.4.0')
% This is a pre-R2014b Matlab: No longer supported by V 3.0.18+
fprintf('Matlab release prior to R2014b detected. This version is no longer\n');
fprintf('supported by Psychtoolbox 3.0.18 and later. Aborted.');
fprintf('\n\nInstallation aborted. Fix the reported problem and retry.\n\n');
return;
end

try
Expand Down

0 comments on commit 5cd3e14

Please sign in to comment.