0
votes

I am having a number of problems with compiling files using mex on matlab r2011a on Mac OS 10.9.2. I know that I need to have the compiler flag -std=gnu++11 in order to make things work. I have updated the mexopts.sh file (~/.matlab/r2011a/mexopts.sh) so that the CXXFLAGS has the required flag added in. However it doesn't seem to be working.

If I look at the compiler configuration:

cc = mex.getcompilerconfigurations('c++')

The returned cc.details.CompilerFlags is not in any way related to the value that is in mexopts.sh. That is probably why things are not working.

Any ideas on how to fix this so that the compiler configuration actually reflects the mexopts.sh file?

1
Did you try running mex -setup and selecting the compiler again, after you made the modifications? - Praetorian
@Praetorian I thought that would just copy a file over my mexopts.sh, but I will try. - dustincarr
It might, so you might want to make a backup :) I have no idea whether that'll actually fix the problem. - Praetorian
It didn't fix it, but it broke it enough that I was able to actually find the problem. I wasn't editing the correct section! - dustincarr
Glad to have helped :D You should post an answer. - Praetorian

1 Answers

1
votes

So I figured this out. I was just missing the fact that there are many different machine-dependent sections in mexopts.sh. Although, I must admit that since mex does not support cross-compilation, as far as I can tell, then Mathworks really should trim down the mexopts.sh during setup to reflect only the settings for the computer on which it is installed.

I just needed to scroll down to the section labeled maci64), and edit the settings there. I added the appropriate flag (-std=gnu++11) to the CXXFLAGS variable, and it works!