Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations waross on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to specify env variables with mex 1

Status
Not open for further replies.

xwb

Computer
Apr 29, 2005
535
GB
Newbie question.

I have environment variables pointing to include directories. I'd like to write something like

mex fred.c -I$(dist)\include -L$(dist)\lib -l libs

The only problem is I can't find the syntax of the environment variables anywhere. I've tried

$dist
%dist - it takes the %d off and I'm left with ist
%dist% - takes the %d off but not the %\
$(dist)
%<dist>%

I've looked through the internet and as much help text as I can find on Matlab but I can't see anything. Maybe they call it something completely different.

Can anyone tell me what the syntax is for environment variables?
 
Replies continue below

Recommended for you

I tend to do my MEXing from a Matlab command prompt rather than from a shell prompt. That way I can build up my MEX command bit by bit and then eval() it. I'd use getenv() to read from the environment and then insert the values. This approach allows me to use the same build m-file for Windows and UNIX.

% Untested

dist=getenv('dist');

command = ['mex fred.c -I$' dist '\include -L$' dist '\lib -l libs']

eval(command)

- Steve
 
Yes I am working from the Matlab prompt. Your solution works well.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top