Well, I have now made the move to Mountain Lion and for a bit it did look quite good, until I had the nerve of trying to start MATLAB. Now, I must admit that the version of MATLAB that I have is by no means the latest, but it does do the work (for those of you who asked, I am running 2008a). So, I realised that the final blow for X11 was given and that Mountain Lion did indeed get rid of it.

I had encountered this issue when upgrading GIMP, and at the time, everything seemed to be working fine with XQuartz. So, there was I thinking to myself “It is just a matter then of re-installing XQuartz and off we go”. How wrong was I! I installed XQuartz, downloaded from here. The first glimpse that things were not quite correct was when I had to tell manually to GIMP the location of X11. Then tried to launch MATLAB and quite quickly the following message popped up:

“X11 does not appear to be installed. X11 version 1.1.3 or greater is required. For OS X 10.5 or later, X11 is available on the OS X installation DVD. Please find and run the Optional Installs.mpkg installer.”

Great thing that Mathworks has told me that, but Apple does not do X11 anymore, so no installing from the DVD, righ?t! Worse still, unlike GIMP, there was no prompt from MATLAB to tell it the location of X11. I tried creating some symbolic links, but this did not work either. Finally, after a lot of fiddling and searching and all, I found a way to run MATLAB successfully. A solution? Oh well here it is:

- Install XQuartz
- Launch XQuartz and from the menu launch an xterm.
- Type the following command first:

*$MATLAB/bin/matlab -maci*

Where *$MATLAB* is the path to your installation. And voilà!

Incidentally, if you are having problems with the graphics in MATLAB, such as the application crashing when plotting and the like, you can type the following command before launching MATLAB as specified above:

*export DYLD_LIBRARY_PATH=/System/Library/Frameworks/JavaVM.framework/Libraries*

Let me know how you get on with this and should you find another alternative solution let me know!

Enjoy!

###### Related articles

- Matlab, X11 and OS X 10.8 (Mountain Lion) (copiancestral.wordpress.com)

It worked straight out of the box for me. When I clicked MATLAB, I was asked to install X11. I was then redirected to XQuartz which I installed. Logged out, logged in. Seems to work.

Ah, I forgot to check which version of MATLAB you have. Mine is 2012a, which might explain the discrepancies.

Yes, Mathworks mentions support from 2012b so probably your version is much more akin to these changes. Thanks for getting in touch.

I keep getting the following error when trying to open Matlab from xterm in XQuartz even after setting the DYLD_LIBRARY_PATH as you suggested. I already have Java installed.

bash-3.2$ /Applications/MATLAB_R2010a.app/bin/matlab

dyld: Library not loaded: /usr/X11/lib/libXext.6.dylib

Referenced from: /Applications/MATLAB_R2010a.app/bin/maci64/MATLAB.app/Contents/MacOS/libmwhg.dylib

Reason: image not found

Trace/BPT trap: 5

Any help? :(

That sort of error makes me think that the X11/XQuartz installation is not corrupt. You can try launching XQuartz on its own and make sure it runs. You can re-install it I suppose, just make sure you trash the current X11 or XQuartz application before doing so.

I assume that you logged out after installing XQuartz as suggested by the installation information.

The currupt X11 idea is also mentioned by MathWorks:

http://bit.ly/MB2ywF

I hope this helps.

Thanks for the suggestion. It worked in a twisted way – I was trying to look up how to uninstall XQuartz and figured that XQuartz is installed in /opt/X11/ as opposed to /usr/X11/, where the latter is the one that Matlab is looking for. So I resolved the problem by simply making a softlink:

sudo ln -s /opt/X11/ /usr/X11

Excellent! That is a very good point! Cheers for the info and keep in touch.

Perfect, thanks a lot for this!

Glad it was of help. What version of Matlab are you using?

same as you, 2008a. i really have to update, though :-)

I know what you mean… :D

Hi,

(a little bit different Problem but perhaps someone here can help me)

I am using Mountain Lion and Matlab 2010a 32bit.

Everything starts without problems but I need the C compiler in a 32bit version (long story).

There are solutions for Matlab2011/2012 (see: http://www.mathworks.de/support/solutions/en/data/1-FR6LXJ/ ) but so far nothing for 2010a.

I tried to apply this solution for my Matlab. Following these steps I still get an error msg:

Error: Did not imbed ‘options.sh’ code

Anyone an idea how to solve this problem ?

I also tried to use the option “mex -arch maci …” running on matlab2011 (maci64) getting following error message:

mex: -arch not a valid option.

I am not sure if there is a matlab2011a version for a 32 architecture??

Did you have a look at the link provided by mathworks that relates to previous versions of the software?

http://www.mathworks.co.uk/support/compilers/previous_releases.html

I hope that helps…

Hi jrogel,

I saw that Xcode 3.2 is supported by Matlab2010a.

So now I installed a second Xcode on my system and reinstalled Matlab.

It seems that Matlab2010 still tries to access the compiler from Xcode4

(indicated by the same error msg:

/Applications/MATLAB_R2010a.app/bin/mex: line 306: gcc-4.0: command not found

/Applications/MATLAB_R2010a.app/bin/mex: line 1058: gcc-4.0: command not found)

Do you have any idea how to tell Matlab to access now Xcode3.2? Or what do I have to change to make it run ??

Thanks for your help.

Hey.

I’m now able to open matlab, but it still crashes even when putting export DYLD_LIBRARY_PATH=/System/Library/Frameworks/JavaVM.framework/Libraries first. I have the same version as you.

Thank you for the clear and helpful post – 2008a now running and plotting on the new mac with OS X 10.8

Next 2008b …

Excellent! I am very glad it was useful to you. Keep in touch.

I’m using Matlab R2012a and, despite being the correct path, the xterm says “Not such file or directory” when following your steps. However, Matlab works. The problem comes when trying to launch Simulink, it crashes and I have to restart Matlab. Do you know any solution to this problem? Thanks!

Hey, thanks for the comment. I don’t use Simulink, so difficult for me to try and replicate the error. Have you tried Matlab directly for assistance?

Since they may be working on how to make it work right on Mountain Lion, I don’t think Matlab assistance help me to solve this problem. Do you think it could be because of the error when using the Xterm? (“Not such file or directory”). Thank you for your reply!

Finally I got it! I used to try launching Simulink without having launched previously X11. Trying to work it out, I went to Matlab preferences and tried to open Simulink preferences. Then, X11 got started automatically and now, any time I launch Simulink, X11 gets started and it works perfectly!

A milion thanks jrogel!

Huello Amadeu,

I’m very pleased to know that it has worked for you, and even better to know that the issue with Simulink was sorted. Keep in touch and enjoy!

J Rogel-Salazar

Help! I’ve been trying to get matlab working for days now with no luck. I came across your blog and I’m hoping you can help me. I upgraded to Mountain Lion, I’m using ver. 2012a (student). I downloaded xquartz as prompted, but when I logged out and back in, matlab still wouldn’t launch. It opens the activate window then closes. When I open the package contents, I’ve already tried to deactivate and activate. It says there’s nothing to deactivate but also says I’m already activated. This tech lingo is pretty foreign to me, so I’m getting really lost. Any help would be so greatly appreciated!

-alyson

Hello Alyson, thanks for your message. I am not sure I can be of assistance. The version of Matlab that I have is a bit older than yours and thus I cannot reproduce the problem you have. Perhaps if you are more specific regarding the error message(s) that you get people might have a better idea of the problem you have. Given that you are using a 2012a version perhaps you can contact Mathworks directly as you may still qualify for support.

J Rogel-Salazar

I’m not getting any error message at all. It just tries to open the activate window then closes on it’s own. No message. Their tech line isn’t open on the weekends and I’m desperately trying to get it running today. Thanks for the quick response though! I’ll keep looking.

Hello again! Doing a search with this sort of thing I came across the following problem described by MathWorks: After upgrading to Mountain Lion, MATLAB cannot start. It either completely refuses to launch without any errors or it shows license manager error 9.

They say that 2012a is currently not supported for use with Mountain Lion, but they recommend reactivating your copy. Have a look at this page:

http://www.mathworks.co.uk/support/solutions/en/data/1-JE1GKQ/index.html?solution=1-JE1GKQ

It sounds like I have the exact same problem as Alyson does with MATLAB 2012a Student. I’ve downloaded XQuartz, the MATLAB icon flashes for a bit and then just closes. When I use the steps in this article in XQuartz I get the error

“/Applications/MATLAB_R2012a_Student.app/bin/matlab -maci

matlab: No MATLAB bin directory for this machine architecture.

ARCH = maci”

I’ll try and get in contact with Mathworks.

Hi, Just an update. I followed the instructions on http://www.mathworks.com.au/support/solutions/en/data/1-JE1GKQ/index.html?solution=1-JE1GKQ and reinstalled MATLAB and it is now working

Hello, thanks for the message. No idea what the problem might be, more info is needed. Have you followed the advise and checked what the log file says?

J Rogel

I think I figured out the problem. It seems to be an issue with the Java version. However, I’m unable to force the installer to use the 32 bit version instead of the 64 bit version. Still looking for a workaround!

Hello Naren,

thanks for the comment. I am not sure if this may help but have you had a look at this:

http://www.mathworks.co.uk/support/solutions/en/data/1-1812J/

Best wishes,

J Rogel