Variables in call to mex
3 views (last 30 days)
Show older comments
I want to compile about 20 cpp files using the same include and library directories. For this reason, I want to define the directories once and then use them as variables in the mex calls. If I have
mex file1.cpp -LC:/folder1 -LC:/folder2 -LC:/folder3
mex file2.cpp -LC:/folder1 -LC:/folder2 -LC:/folder3
mex file3.cpp -LC:/folder1 -LC:/folder2 -LC:/folder3
I would instead like to write
FOLDER1='C:/folder1'
FOLDER2='C:/folder2'
FOLDER3='C:/folder3'
mex file1.cpp -LFOLDER1-LFOLDER2 -LFOLDER3
mex file2.cpp -LFOLDER1-LFOLDER2 -LFOLDER3
mex file3.cpp -LFOLDER1-LFOLDER2 -LFOLDER3
but it does not seem to work?
0 Comments
Accepted Answer
Geoff Hayes
on 5 Oct 2014
Anders - the way you are doing this is probably leading to some warnings such as
ld: warning: directory not found for option '-LFOLDER1'
ld: warning: directory not found for option '-LFOLDER2'
ld: warning: directory not found for option '-LFOLDER3'
FOLDER1='C:/folder1';
FOLDER2='C:/folder2';
FOLDER3='C:/folder3';
for k=1:20
cmd = sprintf('mex file%d.cpp -L%s -L%s -L%s',k,FOLDER1,FOLDER2,FOLDER3);
eval(cmd);
end
Note that each iteration of the loop will build a string such as
'mex file1.cpp -LC:/folder1 -LC:/folder2 -LC:/folder3'
which has the folder variables "built" in to the command string.
0 Comments
More Answers (1)
See Also
Categories
Find more on MATLAB Compiler in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!