Multiple include paths in mex

조회 수: 35 (최근 30일)
matuser123
matuser123 2016년 4월 19일
답변: Philip Borghesani 2016년 4월 19일
I have a source file with headers in multiple directories that I'm compiling.
mex -v -IC:\working\tempInclude1 -IC:\working\tempInclude2 mexTest.cpp
returns
arguments = -IC:\working\tempInclude1 -IC:\working\tempInclude2
and works fine. But if I try to use the syntax below,
srcFile = 'mexTest.cpp';
ipath = ['-I' fullfile(pwd,'tempInclude1') ' -I' fullfile(pwd,'tempInclude2')];
mex('-v',ipath,srcFile)
it returns
arguments = -I"C:\working\tempInclude1 -IC:\working\tempInclude2"
and that double quote causes the command to fail. Any ideas? When I look at ipath, there is no quote in it.

채택된 답변

Philip Borghesani
Philip Borghesani 2016년 4월 19일
You need to use two different variables or a cell array of paths:
path1 = ['-I' fullfile(pwd,'tempInclude1')];
path2 = ['-I' fullfile(pwd,'tempInclude2')];
mex('-v',path1,path2,srcFile)
or
ipaths = {['-I' fullfile(pwd,'tempInclude1')], ['-I' fullfile(pwd,'tempInclude2')];}
mex('-v',ipaths{:}, srcFile)
I suggest reading up on how command mode differs from function calling mode. matlab command syntax vs function syntax

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 MATLAB Compiler에 대해 자세히 알아보기

태그

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by