How do I compile a MEX file from a source file that is not located in my current working directory?

15 views (last 30 days)
I am able to compile my MEX file (myMexFile.c) present in the current working directory successfully using the MEX command.
However when I attempt to compile the same MEX file after moving it to a different location on my system using the following command:
mex myMexFile.c
I receive the following error message:
C:\PROGRA~2\MATLAB\R2007B\BIN\MEX.PL: Error: 'myMexFile.c' not found.
??? Error using ==> mex at 208
Unable to complete successfully.

Accepted Answer

MathWorks Support Team
MathWorks Support Team on 11 Sep 2009
It is possible to compile source MEX files located in any folder on your system. To do this, you would have to specify the full path to the source file. For example, if your current working directory is
C:\matlab\work
and your source file (mexMexFile.c) is present in
C:\test
execute the MEX command as shown below to compile this file.
mex C:\test1\myMexFile.c
The output MEX file will be created in your current working directory.

More Answers (0)

Categories

Find more on Write C Functions Callable from MATLAB (MEX Files) in Help Center and File Exchange

Products

Community Treasure Hunt

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

Start Hunting!