5

I've upgraded my MATLAB to 2014b (on OS X 10.10), and tried to test some old MEX C/C++ codes.

As usual, I run mex -setup from the command window, and I would expect to be provided the chance to overwrite the option file "meshopt.sh".

But now, it seems MATLAB has made some change and I am not allowed to change the MEX configuration, it simply says:

MEX configured to use Xcode with Clang for C language compilation,
...
to choose a different language, select one from the following

mex -setup C++
mex -setup FORTRAN

So, is it true that the old ways to modify "mexopts.sh" are no longer feasible?

Nisse Engström
  • 4,738
  • 23
  • 27
  • 42
lorniper
  • 626
  • 1
  • 7
  • 29
  • You can always check to see if the file is there in the `mex` directory of your MATLAB distribution once you choose one of these setups then modify the file that way.... but if this is seriously the case, then it's a crying shame. I won't upgrade to 2014b then! – rayryeng Oct 17 '14 at 14:30
  • I'm still on R2014a so I can't verify myself, but can you try calling something like `mex -f my_mexopts.sh ...` where `my_mexopts.sh` is the configuration file from previous versions? – Amro Oct 17 '14 at 14:39
  • @Amro it says "An invalid options file name was specified". – lorniper Oct 17 '14 at 15:04
  • @lorniper: you did replace `my_mexopts.sh` with the name of your actual config file, right? – Amro Oct 17 '14 at 15:30
  • @Amro, sure..anyway, disappointing.. – lorniper Oct 17 '14 at 15:34
  • Anyway MATLAB switched to using XML config files, so in theory you could customize those instead. Look in your preference folder `prefdir()` for files like `mex_C++_win64.xml` or the equivalent for OSX – Amro Oct 17 '14 at 15:39
  • @Amro Finally I found some workaround, it's strange that mathworks suggest "Using the 'mexsh -setup' command selects an options file that is placed in /Users/user1/.matlab/R2014b", however, I don't even have the mexsh command on R2014b ! – lorniper Oct 17 '14 at 15:56

2 Answers2

1

It seems that the following command works:

mex -setup my_mexopts.sh

however, there's some warning information,

Legacy MEX infrastructure is provided for compatibility; it will be removed in a future version of MATLAB.

Apart from that, everything looks fine, except I got some warning at compile time seems due to compiler version(gcc 4.9.1) on my current system(OS X 10.10).

gcc: warning: couldn't understand kern.osversion '14.0.0

lorniper
  • 626
  • 1
  • 7
  • 29
1

When I run mex -setup C, I see information like the following:

Microsoft Visual C++ 2008 (C)  mex -setup:H:\MATLAB\R2014b\bin\win64\mexopts\msvc2008.xml C
Microsoft Visual C++ 2010 (C)  mex -setup:H:\MATLAB\R2014b\bin\win64\mexopts\msvc2010.xml C
Microsoft Visual C++ 2012 (C)  mex -setup:H:\MATLAB\R2014b\bin\win64\mexopts\msvc2012.xml C

The mex part is actually a link you can click to choose that configuration. So, to make your own:

  1. Choose an xml as a template and copy it. (e.g I'd copy H:\MATLAB\R2014b\bin\win64\mexopts\msvc2012.xml to %AppData%\MathWorks\MATLAB\R2014b\mex_C++_win64_custom.xml).
  2. Make the edits in the XML file, probably in the <vars> tag (e.g. modify COMPFLAGS or CFLAGS whatever variable has your compiler options) or the <env> tag (e.g. PATH, INCLUDE, LIB, etc.)
  3. Set that to the current configuration:

    mex -setup:C:\[YourMATLABAppDataHere]\myCopts.xml C
    

Note that a good place in Windows to keep settings is under %APPDATA%. For MATLAB R2014b, this would be something like C:\Users\[yourname]\AppData\Roaming\MathWorks\MATLAB\R2014b.

Do the same for C++ or FORTRAN configurations too.

chappjc
  • 30,359
  • 6
  • 75
  • 132