-
Notifications
You must be signed in to change notification settings - Fork 4
/
compile_daqcomm.m
39 lines (31 loc) · 1.54 KB
/
compile_daqcomm.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
function compile_daqcomm()
% Only support modern enough compilers
cCompiler = mex.getCompilerConfigurations('C','Selected');
if ~strncmpi(cCompiler.ShortName', 'msvc', 4) ...
|| str2double(cCompiler.Version) < 11
fprintf('!! WARNING: This is only supported for Microsoft Visual C++ 2012 and newer. Doing nothing.\n');
return;
end
% Code files to compile
code = { 'nidaqPulse.cpp' ...
, 'nidaqTest.cpp' ...
, 'nidaqI2C.cpp' ...
, 'nidaqPulse2.cpp' ...
, 'nidaqPulse3.cpp' ...
, 'nidaqPulse4.cpp' ...
};
% NI-DAQ environment
nidaqDir = fullfile(getenv('NIDAQmxSwitchDir'), '..', '..', 'Shared', 'ExternalCompilerSupport', 'C');
mexOpts = { ['-I' fullfile(nidaqDir, 'include')] ...
, ['-L' fullfile(nidaqDir, ['lib' osBitSize()], 'msvc')] ...
, '-lNIDAQmx' ...
, '-O' ...
};
% Change to the directory that hosts this file (and by assumption the mex code)
origLoc = cd(fullfile(fileparts(mfilename('fullpath')), 'experiments\daq'));
for iCode = 1:numel(code)
fprintf('==================== Compiling %s ====================\n', code{iCode});
fprintf(' mex%s\n', sprintf(' %s', code{iCode}, mexOpts{:}));
mex(code{iCode}, mexOpts{:});
end
cd(origLoc);