15
15
% missing or dysfunctional Screen mex files properly.
16
16
% _________________________________________________________________________
18
% See also: AssertOpenGL, COMPUTER, IsOSX, IsOS9, IsWin
18
% See also: AssertOpenGL, COMPUTER, IsOSX, IsWin
24
24
% 12/14/03 awi Wrote it
25
25
% 07/02/04 awi Improved documentation: Added See also, explained
26
26
% behavior when no arguments are supplied.
27
27
% Changed name to AssertMex from PsychAssertMex
28
28
% 10/03/04 awi Modified to accept 'WINDOWS', 'OS9', 'OSX'
29
29
% 01/08/05 fwc fixed little bug, see comments
30
% 01/11/05 awi Merged fwc fix into psychtoolbox.org master copy.
30
% 01/11/05 awi Merged fwc fix into psychtoolbox.org master copy.
31
31
% 01/29/05 dgp Cosmetic.
32
32
% 03/07/05 fwc Fixed bugs due to which failed Assertmex to accept 'OSX', 'OS9' as valid input.
33
33
% In line 80/81 badNames was often {''} which is not empty for isempty().
34
34
% Also changed || into | in line 90
35
35
% 03/08/05 dgp Add support for 'WIN'.
36
% 10/06/05 awi Fixed bug: Changed "okSupNameMatches" to match addition of 'WIN' to
36
% 10/06/05 awi Fixed bug: Changed "okSupNameMatches" to match addition of 'WIN' to
38
38
% 3/3/06 awi Rewrote help for improved clarity.
39
39
% 6/13/09 mk Update to handle execution failures and missing files
40
40
% on Octave-3.2 et al. as well.
41
% 5/28/12 mk Update: 64-Bit OSX and Linux supported, but OSX PowerPC
42
% and Matlab < V7.4 (aka R2007a) no longer supported.
42
44
persistent okNames mexExtensions;
44
46
% Different processing on Octave build.
46
48
myName = char(varargin{1});
47
if isempty(findstr(myName, '.m'))
49
if isempty(strfind(myName, '.m'))
51
53
octFilename = [ myName(1:end-1) 'mex'];
52
54
fprintf('\nIn place of the expected Octave .mex binary plugin file this placeholder file was executed:\n\n');
53
55
fprintf([' ' myName '\n\n']);
54
56
fprintf('This MEX file seems to be missing or inaccessible on your Octave path or it is dysfunctional:\n\n')
55
57
fprintf([' ' octFilename '\n\n']);
57
59
fpath = which(myName(1:end-2));
59
61
fprintf('Hmm. I cannot find the file on your Octave path?!?\n\n');
63
65
fprintf('Make sure that the path is readable by you as well...\n');
65
67
% Some file with such a function exists on the Octave path:
66
[dum1, dum2, fpathext] = fileparts(fpath);
68
[dum1, dum2, fpathext] = fileparts(fpath); %#ok<ASGLU>
67
69
% Proper extension for the .mex file?
68
70
if isempty(strfind(fpathext, '.mex'))
69
71
% Nope, wrong file bound:
73
oext = ['64' filesep];
71
fprintf('The following directory should be the *first one* on your Octave path:\n %s \n\n', [PsychtoolboxRoot 'PsychBasic/Octave3LinuxFiles/']);
79
fprintf('The following directory should be the *first one* on your Octave path:\n %s \n\n', [PsychtoolboxRoot 'PsychBasic/Octave3LinuxFiles' oext]);
74
fprintf('The following directory should be the *first one* on your Octave path:\n %s \n\n', [PsychtoolboxRoot 'PsychBasic/Octave3OSXFiles/']);
82
fprintf('The following directory should be the *first one* on your Octave path:\n %s \n\n', [PsychtoolboxRoot 'PsychBasic/Octave3OSXFiles' oext]);
77
fprintf('The following directory should be the *first one* on your Octave path:\n %s \n\n', [PsychtoolboxRoot 'PsychBasic\Octave3WindowsFiles\']);
85
fprintf('The following directory should be the *first one* on your Octave path:\n %s \n\n', [PsychtoolboxRoot 'PsychBasic\Octave3WindowsFiles' oext]);
80
88
fprintf('\n\nIf you have just installed Psychtoolbox, it worked properly and suddenly stopped working\n');
101
109
% Initialize the persistent variables.
102
110
if isempty(okNames)
103
okNames = {'PCWIN', 'PCWIN64', 'SOL2', 'HPUX', 'HP700', 'ALPHA', 'IBM_RS', 'SGI', 'GLNX86', 'MAC', 'MAC2', 'MACI', 'i486-pc-linux-gnu', 'MACI64', 'GLNXA64' };
104
mexExtensions = {'dll', 'dll', '*', '*', '*', '*', '*', '*', '*', 'mexmac', 'mex', 'mexmaci', 'oct', 'mexmaci64', '*' };
111
okNames = { 'PCWIN', 'PCWIN64', 'SOL2', 'HPUX', 'HP700', 'ALPHA', 'IBM_RS', 'SGI', 'GLNX86', 'MAC', 'MAC2', 'MACI', 'i486-pc-linux-gnu', 'MACI64', 'GLNXA64' };
112
mexExtensions = {'mexw32', 'mexw64', '*', '*', '*', '*', '*', '*', 'mexglx', 'mexmac', 'mex', 'mexmaci', 'mex', 'mexmaci64', 'mexa64' };
109
117
% Check to see if there should be a mex file for our platform.
110
if isempty(inputNames) | ismember(computer, inputNames) %#ok<OR2>
118
if isempty(inputNames) || ismember(computer, inputNames)
111
119
% Element 1 will always be AssertMex. Element 2 will be the calling
112
120
% function unless it is invoked from the commnand line.
113
121
callStack = dbstack;
115
123
if length(callStack) > 1
116
124
callerName = callStack(2).name;
118
126
error('AssertMex was invoked from the command line.');
121
129
% Generate error strings
122
130
extensionNameIndex=find(streq(computer,okNames));
123
extensionName=mexExtensions{extensionNameIndex};
124
mExtensionIndices=findstr('.m',callerName);
131
extensionName=mexExtensions{extensionNameIndex}; %#ok<FNDSB>
132
mExtensionIndices=strfind('.m',callerName);
125
133
if ~isempty(mExtensionIndices)
126
134
termExtension=mExtensionIndices(end);
127
135
mexFilenameHead=callerName(1:termExtension-1);
135
143
fprintf([' ' mexFilename '\n\n']);
137
145
if isempty(which(mexFilename))
138
fprintf('Hmm. I cannot find the file on your Matlab path?!?\n\n');
139
fprintf('One reason could be that your Matlab path is wrong or not up to date\n');
140
fprintf('for the current Psychtoolbox. You may want to run SetupPsychtoolbox to \n');
141
fprintf('fix possible path problems.\n\n');
146
if strcmp(computer, 'MAC')
148
fprintf('Matlab running on MacOSX on a PowerPC based Apple Macintosh computer is no longer supported.\n');
149
fprintf('You would need to get a version 3.0.9 or earlier Psychtoolbox for this to work on your computer.\n');
150
fprintf('Or upgrade your computer to run a modern version of GNU/Linux and use the Psychtoolbox for Linux on PowerPC.\n\n');
151
elseif (IsWin && exist('mexext') && strcmp(mexext, 'dll')) %#ok<EXIST>
152
% Windows with Matlab pre-R2007a:
153
fprintf('Matlab versions older than V7.4 aka R2007a running on MS-Windows are no longer supported by this release.\n');
154
fprintf('Install GNU/Octave or a more modern Matlab version instead. Or downgrade to Psychtoolbox version 3.0.9 or earlier.\n\n');
156
fprintf('Hmm. I cannot find the file on your Matlab path?!?\n\n');
157
fprintf('One reason could be that your Matlab path is wrong or not up to date\n');
158
fprintf('for the current Psychtoolbox. You may want to run SetupPsychtoolbox to \n');
159
fprintf('fix possible path problems.\n\n');
144
fprintf('It is important that the folder which contains the Screen.dll file is located *before*\n');
145
fprintf('the PsychBasic folder on your Matlab path. On Matlab prior to V7.4, the folder\n');
146
fprintf('%sPsychBasic\\MatlabWindowsFilesR11\\ must be before the folder\n%sPsychBasic\\ \n\n', PsychtoolboxRoot, PsychtoolboxRoot);
163
fprintf('It is important that the folder which contains the Screen mex file is located *before*\n');
164
fprintf('the PsychBasic folder on your Matlab path.\n');
147
165
fprintf('On Matlab V7.4 (R2007a) or later versions, the folder\n');
148
166
fprintf('%sPsychBasic\\MatlabWindowsFilesR2007a\\ must be before the folder\n%sPsychBasic\\ \n\n', PsychtoolboxRoot, PsychtoolboxRoot);
149
167
fprintf('type path to display the current path and check for this condition.\nIf the order is wrong, ');
150
168
fprintf('simply cd into your Psychtoolbox root folder\n%s and then run SetupPsychtoolbox again.\n', PsychtoolboxRoot);
151
169
fprintf('That is the simplest way of fixing such path problems - Or to get more diagnostic output.\n\n');
154
172
fprintf('Another reason could be insufficient access permissions or \n');
155
173
fprintf('some missing 3rd party libraries on your system.\n\n');
158
fprintf('On Microsoft Windows with recent Matlab versions (>= V7.4) it could also be that\n');
159
fprintf('the required Visual C++ 2005 runtime libraries are missing on your system.\n');
160
fprintf('Visit http://www.mathworks.com/support/solutions/data/1-2223MW.html for instructions how to\n');
161
fprintf('fix this problem. Make sure you follow the download link to Visual Studio SERVICE PACK 1,\n');
162
fprintf('(the latter links), *not* Visual Studio without the SP1.\n\nAfter fixing the problem, retry.\n\n');
164
if strcmp(computer,'PCWIN64')
165
% 64 bit Matlab running on 64 bit Windows?!? That won't work.
166
fprintf('And another possible reason for failure:\n\n');
167
fprintf('It seems that you are running a 64-bit version of Matlab on your system.\n');
168
fprintf('That won''t work at all! Psychtoolbox currently only supports 32-bit versions\n');
169
fprintf('of Matlab.\n');
170
fprintf('You can try to exit Matlab and then restart it in 32-bit emulation mode to\n');
171
fprintf('make Psychtoolbox work on your 64 bit Windows. You do this by adding the\n');
172
fprintf('startup option -win32 to the matlab.exe start command, ie.\n');
173
fprintf('matlab.exe -win32\n');
174
fprintf('If you do not know how to do this, consult the Matlab help about startup\n');
175
fprintf('options for Windows.\n\n');
176
fprintf('On Microsoft Windows with supported Matlab versions (>= V7.4) it could also be that\n');
177
fprintf('the required Visual C++ 2010 runtime libraries are missing on your system.\n');
178
fprintf('The Psychtoolbox/PsychContributed/ subfolder contains installer files for them, which\n');
179
fprintf('you can execute after quitting Matlab. The name of the file is ');
181
fprintf('vcredist_x64.exe\n');
183
fprintf('vcredist_x86.exe\n');
179
if IsOSX & strcmp(computer,'MACI64') %#ok<AND2>
180
% 64 bit Matlab running on 64 bit OS/X?!? That won't work.
181
fprintf('And another possible reason for failure:\n\n');
182
fprintf('It seems that you are running a 64-bit version of Matlab on your system.\n');
183
fprintf('That won''t work at all! Psychtoolbox currently only supports 32-bit versions\n');
184
fprintf('of Matlab.\n');
185
fprintf('You can try to exit Matlab and then restart it in 32-bit emulation mode to\n');
186
fprintf('make Psychtoolbox work on your 64 bit OS/X. You do this by adding the\n');
187
fprintf('startup option -maci to the matlab start command, ie.\n');
188
fprintf('matlab -maci\n');
189
fprintf('If you do not know how to do this, consult the Matlab help about startup\n');
190
fprintf('options for OS/X.\n\n');
193
if IsLinux & strcmp(computer,'GLNXA64') %#ok<AND2>
194
% 64 bit Matlab running on 64 bit Linux?!? That won't work.
195
fprintf('And another possible reason for failure:\n\n');
196
fprintf('It seems that you are running a 64-bit version of Matlab on your system.\n');
197
fprintf('That won''t work at all! Psychtoolbox currently only supports 32-bit versions\n');
198
fprintf('of Matlab. One exception is if you got this Psychtoolbox from the NeuroDebian\n');
199
fprintf('project repository: http://neuro.debian.net, in which case 64 bit Matlab and Octave\n');
200
fprintf('should be fully supported, so the reason for failure is not 64 bit problems.\n');
201
fprintf('You can try to exit Matlab and then restart it in 32-bit emulation mode to\n');
202
fprintf('make Psychtoolbox work on your 64 bit Linux.\n'); % You do this by adding the\n');
203
% fprintf('startup option -maci to the matlab start command, ie.\n');
204
% fprintf('matlab -maci\n');
205
fprintf('If you do not know how to do this, consult the Matlab help about startup\n');
206
fprintf('options for Linux.\n\n');
210
187
error('Missing or dysfunctional Psychtoolbox Mex file for this operating system. Read the help text above carefully!!');