×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Contact US

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

How to specify env variables with mex

How to specify env variables with mex

How to specify env variables with mex

(OP)
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?

RE: How to specify env variables with mex

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

RE: How to specify env variables with mex

(OP)
Yes I am working from the Matlab prompt.  Your solution works well.

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members! Already a Member? Login



News


Close Box

Join Eng-Tips® Today!

Join your peers on the Internet's largest technical engineering professional community.
It's easy to join and it's free.

Here's Why Members Love Eng-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close