-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcompile.m
70 lines (51 loc) · 1.63 KB
/
compile.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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
function compile()
%% UPDATE THESE PATHS
zlibpath = 'zlib\lib';
exrpath = 'openexrstatic\';
checkpaths(zlibpath, exrpath);
% Static libraries
libs = {'IlmImf-2_5', 'IlmImfUtil-2_5', 'Half-2_5', ...
'Iex-2_5', 'IexMath-2_5', 'IlmThread-2_5', ...
'Imath-2_5','zlibstatic'};
cppfiles = {'exrread.cpp', 'exrwrite.cpp', 'exrinfo.cpp'};
% library commands
for i = 1 : numel(libs)
libcmd{i} = sprintf('-l%s ',libs{i});
end
libs = cat(2, libcmd{:});
% Include path
exrincpath = fullfile(exrpath, 'include', 'OpenEXR');
ipath = sprintf('-I%s ', exrincpath);
% Library paths
exrlibpath = fullfile(exrpath, 'lib');
lpath = sprintf('-L%s -L%s ',exrlibpath,zlibpath);
for i = 1 : numel(cppfiles)
mcmd = sprintf('mex %s %s %s %s',cppfiles{i},libs,ipath,lpath);
fprintf('Compiling %s...',cppfiles{i});
[status,cmdout] = system(mcmd);
if status == 0
fprintf('Done\n');
else
fprintf('Error %s\n',cmdout);
end
end
end
%
% Test that the paths exist
%
function checkpaths(zlibpath, exrpath)
if ~exist(zlibpath, 'dir')
error('cannot find zlib path %s',zlibpath);
end
if ~exist(exrpath, 'dir')
error('cannot find OpenEXR path %s',exrpath);
end
exrincpath = fullfile(exrpath, 'include', 'OpenEXR');
if ~exist(exrincpath, 'dir')
error('cannot find OpenEXR include path %s',exrincpath);
end
exrlibpath = fullfile(exrpath, 'lib');
if ~exist(exrlibpath, 'dir')
error('cannot find OpenEXR lib path %s',exrlibpath);
end
end