Skip to Main Content Skip to Search
Home |   Select Country  Choose Country  |  Contact Us  |  Cart Store 
Create Account | Log In
Products & Services Solutions Academia Support User Community Company
spacer spacer spacer spacer spacer spacer

Technical Solutions

Why am I unable to use MEX on Solaris 10 in MATLAB 7.0.4 (R14SP2)?


Date Last Modified: Friday, June 26, 2009
Solution ID:   1-14ZQS4
Product:   MATLAB
Reported in Release:   R14SP2
Fixed in Release:   R2006a
Platform:   Solaris
Operating System:   Solaris Any
 

Subject:

Why am I unable to use MEX on Solaris 10 in MATLAB 7.0.4 (R14SP2)?

Problem Description:

I am using the Solaris 10 ANSI C compiler to compile the yprime.c MEX-file located in $MATLAB/extern/examples/mex (where $MATLAB is the MATLAB installation directory, which is returned by typing "matlabroot" at the MATLAB command prompt). When I execute the following code:
mex yprime.c
I receive the following error:
"/usr/include/sys/feature_tests.h", line 332: #error: "Compiler or
options invalid for pre-UNIX 03 X/Open applications and pre-2001
POSIX applications"
cc: acomp failed for yprime.c

mex: compile of 'yprime.c' failed.

??? Error using ==> mex
Unable to complete successfully

Solution:

This bug has been fixed in Release 2006a (R2006a). For previous product releases, read below for any possible workarounds:

We have verified that there has been a change in the Solaris 10 system ANSI C compiler that causes this error. The critical part of the error message is:
"Compiler or options invalid for pre-UNIX 03 X/Open applications and pre-2001 POSIX applications"
The Solaris 10 system ANSI C compiler (cc) is no longer tolerant of implicit support for ISO C99 standard features. The compiler now requires that you explicitly enable C99 features by using either the -xc99 flag or by some other means, such as an _XOPEN_SOURCE=600 macro, even if you do not use any of these features.

To fix this error use the following steps:

1. Rename the file, $MATLAB/bin/mexopts.sh to mexopts.sh.old
(Where the term $MATLAB represents the MATLAB installation directory.)
2. Download the attached file, mexopts.tar, to $MATLAB/bin
3. Extract the file mexopts.sh from mexopts.tar. In MATLAB you can use the UNTAR function to do this. Once you have extracted mexopts.sh you can delete mexopts.tar.
4. At the command prompt, execute:
mex -setup
.
5. Select the "system ANSI C compiler". This should now refer to the file you just downloaded.

 

Related Documents/Files:

Please provide feedback to help us improve this Solution
Contact support
E-mail this page
Print this page