How do I troubleshoot errors in MATLAB with mex -setup or mbuild -setup?

7 views (last 30 days)
I would like to find a solution for the following error message:
error using 'mex', unable to complete successfully
Sometimes when I run
mex -setup
and select Lcc as the C compiler, the programs quits saying that lcc is not "within the matlab directory". Lcc is under \matlab\sys\lcc . I checked the mex.m and mex.bat files. They seem to be looking at the correct directory but the program exits with the above mentioned error message.

Accepted Answer

MathWorks Support Team
MathWorks Support Team on 14 Apr 2011
You can use the following questions and steps to troubleshoot these errors:
1. Can you use MEX or 'mex -setup' from the DOS command prompt successfully? If not, does the -v output show anything more? (for example, mcc -m -v hello.m)
2. When you installed your compiler (i.e. Microsoft Visual C/C++) you can specify the directories in which to install the product. Did you choose a different directory for C/C++ and the Visual components? If you did, MEX will not be able to find the (MSVC) compiler command line tools correctly.
3. What is the path to your compiler? To MATLAB? Please make sure that these paths do not contain spaces.
Comments:
If the compiler hangs and no error message is printed out, it is usually the result of one of the following:
1. The DOS %PATH% variable is incorrect. Make sure that $MATLAB\bin\win32 (where $MATLAB is the root installation directory of MATLAB) is included in your system PATH variable. On Windows OS, the path should look similar to the following:
C:\matlabr12\bin\win32;%SYSTEMROOT%\system;c:\winnt;
Which is resolved to
C:\matlabr12\bin\win32;c:\winnt\system;c:\winnt
Refer to the Related Solution listed at the bottom of the page for the necessary directories needed to run MEX and MBUILD correctly.
2. If the C compiler was installed incorrectly, it will not run, because it cannot find some libraries that it is dependent upon. No error is produced in this situation.
You should also make sure you have the most recent version of the MATLAB Compiler, and C/C++ Math and Graphics Libraries, if you are running the most recent version of MATLAB. For example, with MATLAB 6.0, you should have versions 2.1 for all of these products.
In many cases similar to this, the errors are due to a conflict between MATLAB and your anti-virus software. Although the problem may not be limited to these products, we have reproduced this problem in house with the Cheyenne AntiVirus and Dr. Solomon virus checkers.
To work around this conflict, temporarily disable the virus checker when running "mex -setup" or "mbuild -setup" and reboot. After you have successfully run the setup operation, you can re-enable your anti-virus software.
For the problem with MATLAB quitting after running mex -setup and when it is not able to find Lcc even though it is there, disabling any virus scanner application (if running) has solved the problem.

More Answers (0)

Categories

Find more on MATLAB Compiler 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!