Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
MEX Setup for Mac OS X 10.6

Subject: MEX Setup for Mac OS X 10.6

From: Christian

Date: 11 Feb, 2010 21:44:04

Message: 1 of 14

Hello,

I'm trying to setup a mex compiler for MATLAB R2009b (64bit), running on a Mac Intel 64bit, OS X 10.6 and the newest version of Apple XCode (3.2.1).

I've run mex -setup, but MATLAB cannot locate the g++/gcc compiler. Is there any general walkthrough for setting up the compiler for a 64-bit system?

Thanks,
-Christian

Subject: MEX Setup for Mac OS X 10.6

From: Brian Arnold

Date: 11 Feb, 2010 22:21:23

Message: 2 of 14

Hi Christian,

Are you sure you installed Xcode developer tools? The installer is on
your Mac OS X install DVD. Do you have a folder named "Developer" on
your local hard drive? If you open Terminal, and type 'gcc --version'
what is returned? If Terminal can't find gcc either, then the tools are
not installed.

If you need more help than this, please troubleshoot (Google might help)
and provide more details.

- Brian

Christian wrote:
> Hello,
>
> I'm trying to setup a mex compiler for MATLAB R2009b (64bit), running on
> a Mac Intel 64bit, OS X 10.6 and the newest version of Apple XCode (3.2.1).
> I've run mex -setup, but MATLAB cannot locate the g++/gcc compiler. Is
> there any general walkthrough for setting up the compiler for a 64-bit
> system?
>
> Thanks,
> -Christian

Subject: MEX Setup for Mac OS X 10.6

From: Robert

Date: 7 Apr, 2010 15:08:06

Message: 3 of 14

Hi Brian, since Christian didn't respond I'm going to ask this for him. I am running OSX 10.6.2, and I have XCode 3.1.2. I'm not sure why I don't have XCode 3.2, but I'm downloading it now. If I look in Developer/usr/bin/ there are files named gcc-4.0 and gcc-4.2, as well as an alias named gcc that's currently pointing to gcc-4.0.

I just tried typing 'gcc --version' in Terminal, which replies 'gcc: command not found'. Can you please help? It looks to me like gcc is on my computer, so why can neither Terminal nor Matlab find it?

When I run 'mex -setup' in Matlab, I get
'The options files available for mex are:

  1: /Applications/MATLAB_R2010a.app/bin/gccopts.sh :
      Template Options file for building gcc MEX-files
 
  2: /Applications/MATLAB_R2010a.app/bin/mexopts.sh :
      Template Options file for building MEX-files via the system ANSI compiler'

Is this what I should be seeing? All I want to do is run a program i downloaded from Matlab Central that requires calling mex on a .cpp file. Please help, and sorry if I got any of the technical jargon wrong.

~Rob


Brian Arnold <Brian.Arnold@mathworks.com> wrote in message <4B7482E3.2030704@mathworks.com>...
> Hi Christian,
>
> Are you sure you installed Xcode developer tools? The installer is on
> your Mac OS X install DVD. Do you have a folder named "Developer" on
> your local hard drive? If you open Terminal, and type 'gcc --version'
> what is returned? If Terminal can't find gcc either, then the tools are
> not installed.
>
> If you need more help than this, please troubleshoot (Google might help)
> and provide more details.
>
> - Brian
>
> Christian wrote:
> > Hello,
> >
> > I'm trying to setup a mex compiler for MATLAB R2009b (64bit), running on
> > a Mac Intel 64bit, OS X 10.6 and the newest version of Apple XCode (3.2.1).
> > I've run mex -setup, but MATLAB cannot locate the g++/gcc compiler. Is
> > there any general walkthrough for setting up the compiler for a 64-bit
> > system?
> >
> > Thanks,
> > -Christian

Subject: MEX Setup for Mac OS X 10.6

From: Brian Arnold

Date: 8 Apr, 2010 18:26:28

Message: 4 of 14

Hi Robert,

If gcc isn't on the path when you open a new Terminal window ("command
not found") and you know that it's located in /usr/bin, then you
probably have a shell startup script file somewhere that is changing the
PATH environment variable, which can cause all manner of problems (not
just this one).

In Terminal, type 'echo $PATH' and examine what it returns. If it
doesn't start with /usr/bin:, then there's your problem. It's very
likely that if it contains anything besides the default system paths,
then it probably contains the name of the thing that will remind you why
PATH got redefined. You need to locate the offending shell file
redefining PATH, and either fix it or remove it.

Common startup script file names (where ~ means your home directory)
include ~/.login, ~/.bashrc, ~/.bash_login, ~/.bash_profile ~/.cshrc,
~/.xinitrc, ~/.MacOSX/environment.plist, and so on. Type 'ls -la ~' to
find these hidden folders and files and inspect them for lines that
change PATH.

I'd definitely install Xcode 3.2 for OS X 10.6.2 to avoid other issues
and ensure that you have the current gcc compilers, but I don't think
that will resolve your first issue. FWIW, on 10.6.2 with Xcode 3.2, the
gcc alias should point to gcc-3.2, but MATLAB MEX will use an explicit
gcc version number, and not use the alias, which is expected behavior.

Report back if you are having success, or other issues with MATLAB MEX.

Thanks,

- Brian

Robert wrote:
> Hi Brian, since Christian didn't respond I'm going to ask this for him.
> I am running OSX 10.6.2, and I have XCode 3.1.2. I'm not sure why I
> don't have XCode 3.2, but I'm downloading it now. If I look in
> Developer/usr/bin/ there are files named gcc-4.0 and gcc-4.2, as well as
> an alias named gcc that's currently pointing to gcc-4.0.
>
> I just tried typing 'gcc --version' in Terminal, which replies 'gcc:
> command not found'. Can you please help? It looks to me like gcc is on
> my computer, so why can neither Terminal nor Matlab find it?
>
> When I run 'mex -setup' in Matlab, I get
> 'The options files available for mex are:
>
> 1: /Applications/MATLAB_R2010a.app/bin/gccopts.sh : Template
> Options file for building gcc MEX-files
>
> 2: /Applications/MATLAB_R2010a.app/bin/mexopts.sh : Template
> Options file for building MEX-files via the system ANSI compiler'
>
> Is this what I should be seeing? All I want to do is run a program i
> downloaded from Matlab Central that requires calling mex on a .cpp
> file. Please help, and sorry if I got any of the technical jargon wrong.
>
> ~Rob
>
>
> Brian Arnold <Brian.Arnold@mathworks.com> wrote in message
> <4B7482E3.2030704@mathworks.com>...
>> Hi Christian,
>>
>> Are you sure you installed Xcode developer tools? The installer is on
>> your Mac OS X install DVD. Do you have a folder named "Developer" on
>> your local hard drive? If you open Terminal, and type 'gcc --version'
>> what is returned? If Terminal can't find gcc either, then the tools
>> are not installed.
>>
>> If you need more help than this, please troubleshoot (Google might
>> help) and provide more details.
>>
>> - Brian
>>
>> Christian wrote:
>> > Hello,
>> > > I'm trying to setup a mex compiler for MATLAB R2009b (64bit),
>> running on > a Mac Intel 64bit, OS X 10.6 and the newest version of
>> Apple XCode (3.2.1).
>> > I've run mex -setup, but MATLAB cannot locate the g++/gcc compiler.
>> Is > there any general walkthrough for setting up the compiler for a
>> 64-bit > system?
>> > > Thanks,
>> > -Christian

Subject: MEX Setup for Mac OS X 10.6

From: Robert

Date: 12 Apr, 2010 15:50:22

Message: 5 of 14

Thanks for your help. I don't remember making a startup script, and I can't find any .login, .bash, or similar files. 'echo $PATH' gives me '/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin'.

I just upgraded to XCode 3.2 though, and now 'gcc --version' in the Terminal is finding 'i686-apple-darwin10-gcc-4.2.1 (GCC) 4.2.1 (Apple Inc. build 5659)'. Running 'mex -setup' now seems to get the right configuration.

However, now I'm getting errors about "undefined symbols" that look like they're problems with linking. The undefined symbols are functions and classes from other C++ files in the same folder, for which I've added #include lines for the corresponding .h files. In an attempt to troubleshoot I tried running 'mex yprime.c' as suggested at http://www.mathworks.com/support/tech-notes/1600/1605.html. But I cannot even begin to start troubleshooting since Matlab cannot find that file. Why not? I don't think I've removed anything from my path.

Thanks,
~Robert


Brian Arnold <Brian.Arnold@mathworks.com> wrote in message <hpl74k$6cn$1@fred.mathworks.com>...
> Hi Robert,
>
> If gcc isn't on the path when you open a new Terminal window ("command
> not found") and you know that it's located in /usr/bin, then you
> probably have a shell startup script file somewhere that is changing the
> PATH environment variable, which can cause all manner of problems (not
> just this one).
>
> In Terminal, type 'echo $PATH' and examine what it returns. If it
> doesn't start with /usr/bin:, then there's your problem. It's very
> likely that if it contains anything besides the default system paths,
> then it probably contains the name of the thing that will remind you why
> PATH got redefined. You need to locate the offending shell file
> redefining PATH, and either fix it or remove it.
>
> Common startup script file names (where ~ means your home directory)
> include ~/.login, ~/.bashrc, ~/.bash_login, ~/.bash_profile ~/.cshrc,
> ~/.xinitrc, ~/.MacOSX/environment.plist, and so on. Type 'ls -la ~' to
> find these hidden folders and files and inspect them for lines that
> change PATH.
>
> I'd definitely install Xcode 3.2 for OS X 10.6.2 to avoid other issues
> and ensure that you have the current gcc compilers, but I don't think
> that will resolve your first issue. FWIW, on 10.6.2 with Xcode 3.2, the
> gcc alias should point to gcc-3.2, but MATLAB MEX will use an explicit
> gcc version number, and not use the alias, which is expected behavior.
>
> Report back if you are having success, or other issues with MATLAB MEX.
>
> Thanks,
>
> - Brian

Subject: MEX Setup for Mac OS X 10.6

From: Brian Arnold

Date: 14 Apr, 2010 15:29:17

Message: 6 of 14

Hi Robert,

OK. You're now past PATH issues and into build issues.

Are the missing symbols expected to be in the compiled code that you are
linking, or are they expected to be in a separate static or dynamic
library? If you have multiple source files that you want linked into
one library, make sure the file you are compiling for the MEX command is
including all of the source code you need (not just the header files).
If you are linking your code against other libraries, check that all of
the libraries that you need to link against have been built with the
correct symbols, and that you have -l paths to all of the libraries (in
the case of frameworks, -framework...). You may want to use other
command line development tools such as the 'nm' tool to diagnose missing
symbol problems.

To check that MEX is working using yprime.c, make a copy of the file in
your home folder or some other writable location, cd to the folder
containing your copy, and then run 'mex yprime.c'. The file should be
located here:

/Applications/MATLAB_R2010b.app/extern/examples/mex/yprime.c

Check out the other examples for increasing complexity.

Good luck,

- Brian

Robert wrote:
> Thanks for your help. I don't remember making a startup script, and I
> can't find any .login, .bash, or similar files. 'echo $PATH' gives me
> '/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin'.
>
> I just upgraded to XCode 3.2 though, and now 'gcc --version' in the
> Terminal is finding 'i686-apple-darwin10-gcc-4.2.1 (GCC) 4.2.1 (Apple
> Inc. build 5659)'. Running 'mex -setup' now seems to get the right
> configuration.
>
> However, now I'm getting errors about "undefined symbols" that look like
> they're problems with linking. The undefined symbols are functions and
> classes from other C++ files in the same folder, for which I've added
> #include lines for the corresponding .h files. In an attempt to
> troubleshoot I tried running 'mex yprime.c' as suggested at
> http://www.mathworks.com/support/tech-notes/1600/1605.html. But I
> cannot even begin to start troubleshooting since Matlab cannot find that
> file. Why not? I don't think I've removed anything from my path.
>
> Thanks,
> ~Robert
>
>
> Brian Arnold <Brian.Arnold@mathworks.com> wrote in message
> <hpl74k$6cn$1@fred.mathworks.com>...
>> Hi Robert,
>>
>> If gcc isn't on the path when you open a new Terminal window ("command
>> not found") and you know that it's located in /usr/bin, then you
>> probably have a shell startup script file somewhere that is changing
>> the PATH environment variable, which can cause all manner of problems
>> (not just this one).
>>
>> In Terminal, type 'echo $PATH' and examine what it returns. If it
>> doesn't start with /usr/bin:, then there's your problem. It's very
>> likely that if it contains anything besides the default system paths,
>> then it probably contains the name of the thing that will remind you
>> why PATH got redefined. You need to locate the offending shell file
>> redefining PATH, and either fix it or remove it.
>>
>> Common startup script file names (where ~ means your home directory)
>> include ~/.login, ~/.bashrc, ~/.bash_login, ~/.bash_profile ~/.cshrc,
>> ~/.xinitrc, ~/.MacOSX/environment.plist, and so on. Type 'ls -la ~'
>> to find these hidden folders and files and inspect them for lines that
>> change PATH.
>>
>> I'd definitely install Xcode 3.2 for OS X 10.6.2 to avoid other issues
>> and ensure that you have the current gcc compilers, but I don't think
>> that will resolve your first issue. FWIW, on 10.6.2 with Xcode 3.2,
>> the gcc alias should point to gcc-3.2, but MATLAB MEX will use an
>> explicit gcc version number, and not use the alias, which is expected
>> behavior.
>>
>> Report back if you are having success, or other issues with MATLAB MEX.
>>
>> Thanks,
>>
>> - Brian

Subject: MEX Setup for Mac OS X 10.6

From: Robert

Date: 27 Apr, 2010 18:04:20

Message: 7 of 14

Ok, the problem seems to be that the mex command has to include all .cpp files involved in the project at once. So if you have alpha.cpp, bravo.cpp and charlie.cpp that all reference functions or classes defined in each other, you can't just type "mex alpha.cpp" even if it's the main file. You have to type:

"mex alpha.cpp bravo.cpp charlie.cpp"

I think. Can't find anything about that in the documentation though.

Brian Arnold <Brian.Arnold@mathworks.com> wrote in message <hq4n0d$8fl$1@fred.mathworks.com>...
> Hi Robert,
>
> OK. You're now past PATH issues and into build issues.
>
> Are the missing symbols expected to be in the compiled code that you are
> linking, or are they expected to be in a separate static or dynamic
> library? If you have multiple source files that you want linked into
> one library, make sure the file you are compiling for the MEX command is
> including all of the source code you need (not just the header files).
> If you are linking your code against other libraries, check that all of
> the libraries that you need to link against have been built with the
> correct symbols, and that you have -l paths to all of the libraries (in
> the case of frameworks, -framework...). You may want to use other
> command line development tools such as the 'nm' tool to diagnose missing
> symbol problems.
>
> To check that MEX is working using yprime.c, make a copy of the file in
> your home folder or some other writable location, cd to the folder
> containing your copy, and then run 'mex yprime.c'. The file should be
> located here:
>
> /Applications/MATLAB_R2010b.app/extern/examples/mex/yprime.c
>
> Check out the other examples for increasing complexity.
>
> Good luck,
>
> - Brian
>
> Robert wrote:
> > Thanks for your help. I don't remember making a startup script, and I
> > can't find any .login, .bash, or similar files. 'echo $PATH' gives me
> > '/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin'.
> >
> > I just upgraded to XCode 3.2 though, and now 'gcc --version' in the
> > Terminal is finding 'i686-apple-darwin10-gcc-4.2.1 (GCC) 4.2.1 (Apple
> > Inc. build 5659)'. Running 'mex -setup' now seems to get the right
> > configuration.
> >
> > However, now I'm getting errors about "undefined symbols" that look like
> > they're problems with linking. The undefined symbols are functions and
> > classes from other C++ files in the same folder, for which I've added
> > #include lines for the corresponding .h files. In an attempt to
> > troubleshoot I tried running 'mex yprime.c' as suggested at
> > http://www.mathworks.com/support/tech-notes/1600/1605.html. But I
> > cannot even begin to start troubleshooting since Matlab cannot find that
> > file. Why not? I don't think I've removed anything from my path.
> >
> > Thanks,
> > ~Robert
> >
> >
> > Brian Arnold <Brian.Arnold@mathworks.com> wrote in message
> > <hpl74k$6cn$1@fred.mathworks.com>...
> >> Hi Robert,
> >>
> >> If gcc isn't on the path when you open a new Terminal window ("command
> >> not found") and you know that it's located in /usr/bin, then you
> >> probably have a shell startup script file somewhere that is changing
> >> the PATH environment variable, which can cause all manner of problems
> >> (not just this one).
> >>
> >> In Terminal, type 'echo $PATH' and examine what it returns. If it
> >> doesn't start with /usr/bin:, then there's your problem. It's very
> >> likely that if it contains anything besides the default system paths,
> >> then it probably contains the name of the thing that will remind you
> >> why PATH got redefined. You need to locate the offending shell file
> >> redefining PATH, and either fix it or remove it.
> >>
> >> Common startup script file names (where ~ means your home directory)
> >> include ~/.login, ~/.bashrc, ~/.bash_login, ~/.bash_profile ~/.cshrc,
> >> ~/.xinitrc, ~/.MacOSX/environment.plist, and so on. Type 'ls -la ~'
> >> to find these hidden folders and files and inspect them for lines that
> >> change PATH.
> >>
> >> I'd definitely install Xcode 3.2 for OS X 10.6.2 to avoid other issues
> >> and ensure that you have the current gcc compilers, but I don't think
> >> that will resolve your first issue. FWIW, on 10.6.2 with Xcode 3.2,
> >> the gcc alias should point to gcc-3.2, but MATLAB MEX will use an
> >> explicit gcc version number, and not use the alias, which is expected
> >> behavior.
> >>
> >> Report back if you are having success, or other issues with MATLAB MEX.
> >>
> >> Thanks,
> >>
> >> - Brian

Subject: MEX Setup for Mac OS X 10.6

From: Remus

Date: 31 Jul, 2011 22:00:26

Message: 8 of 14

Brian Arnold <Brian.Arnold@mathworks.com> wrote in message <hpl74k$6cn$1@fred.mathworks.com>...
> Hi Robert,
>
> If gcc isn't on the path when you open a new Terminal window ("command
> not found") and you know that it's located in /usr/bin, then you
> probably have a shell startup script file somewhere that is changing the
> PATH environment variable, which can cause all manner of problems (not
> just this one).
>
> In Terminal, type 'echo $PATH' and examine what it returns. If it
> doesn't start with /usr/bin:, then there's your problem. It's very
> likely that if it contains anything besides the default system paths,
> then it probably contains the name of the thing that will remind you why
> PATH got redefined. You need to locate the offending shell file
> redefining PATH, and either fix it or remove it.
>
> Common startup script file names (where ~ means your home directory)
> include ~/.login, ~/.bashrc, ~/.bash_login, ~/.bash_profile ~/.cshrc,
> ~/.xinitrc, ~/.MacOSX/environment.plist, and so on. Type 'ls -la ~' to
> find these hidden folders and files and inspect them for lines that
> change PATH.
>
> I'd definitely install Xcode 3.2 for OS X 10.6.2 to avoid other issues
> and ensure that you have the current gcc compilers, but I don't think
> that will resolve your first issue. FWIW, on 10.6.2 with Xcode 3.2, the
> gcc alias should point to gcc-3.2, but MATLAB MEX will use an explicit
> gcc version number, and not use the alias, which is expected behavior.
>
> Report back if you are having success, or other issues with MATLAB MEX.
>
> Thanks,
>
> - Brian
>
> Robert wrote:
> > Hi Brian, since Christian didn't respond I'm going to ask this for him.
> > I am running OSX 10.6.2, and I have XCode 3.1.2. I'm not sure why I
> > don't have XCode 3.2, but I'm downloading it now. If I look in
> > Developer/usr/bin/ there are files named gcc-4.0 and gcc-4.2, as well as
> > an alias named gcc that's currently pointing to gcc-4.0.
> >
> > I just tried typing 'gcc --version' in Terminal, which replies 'gcc:
> > command not found'. Can you please help? It looks to me like gcc is on
> > my computer, so why can neither Terminal nor Matlab find it?
> >
> > When I run 'mex -setup' in Matlab, I get
> > 'The options files available for mex are:
> >
> > 1: /Applications/MATLAB_R2010a.app/bin/gccopts.sh : Template
> > Options file for building gcc MEX-files
> >
> > 2: /Applications/MATLAB_R2010a.app/bin/mexopts.sh : Template
> > Options file for building MEX-files via the system ANSI compiler'
> >
> > Is this what I should be seeing? All I want to do is run a program i
> > downloaded from Matlab Central that requires calling mex on a .cpp
> > file. Please help, and sorry if I got any of the technical jargon wrong.
> >
> > ~Rob
> >
> >
> > Brian Arnold <Brian.Arnold@mathworks.com> wrote in message
> > <4B7482E3.2030704@mathworks.com>...
> >> Hi Christian,
> >>
> >> Are you sure you installed Xcode developer tools? The installer is on
> >> your Mac OS X install DVD. Do you have a folder named "Developer" on
> >> your local hard drive? If you open Terminal, and type 'gcc --version'
> >> what is returned? If Terminal can't find gcc either, then the tools
> >> are not installed.
> >>
> >> If you need more help than this, please troubleshoot (Google might
> >> help) and provide more details.
> >>
> >> - Brian
> >>
> >> Christian wrote:
> >> > Hello,
> >> > > I'm trying to setup a mex compiler for MATLAB R2009b (64bit),
> >> running on > a Mac Intel 64bit, OS X 10.6 and the newest version of
> >> Apple XCode (3.2.1).
> >> > I've run mex -setup, but MATLAB cannot locate the g++/gcc compiler.
> >> Is > there any general walkthrough for setting up the compiler for a
> >> 64-bit > system?
> >> > > Thanks,
> >> > -Christian


Hi Brian, Rob and anyone else in this feed.

I'm also struggling changing the default compiler. I've recently installed Xcode 3.2. (Its present in the Developer folder). I have gcc ver 4.2.1 but matlab still only gives me the two options when I run mex -setup.

1: /Applications/MATLAB_R2010a.app/bin/gccopts.sh : Template
 Options file for building gcc MEX-files

 2: /Applications/MATLAB_R2010a.app/bin/mexopts.sh : Template
 Options file for building MEX-files via the system ANSI compiler'

Any advice?
Thanks,
Remus

Subject: MEX Setup for Mac OS X 10.6

From: Brian Arnold

Date: 1 Aug, 2011 13:58:32

Message: 9 of 14

Hi Remus,

What kind of problem are you running into? Either MEX option should work
with Xcode 3.2.

Brian

On 7/31/11 6:00 PM, Remus wrote:
> Brian Arnold <Brian.Arnold@mathworks.com> wrote in message
> <hpl74k$6cn$1@fred.mathworks.com>...
>> Hi Robert,
>>
>> If gcc isn't on the path when you open a new Terminal window ("command
>> not found") and you know that it's located in /usr/bin, then you
>> probably have a shell startup script file somewhere that is changing
>> the PATH environment variable, which can cause all manner of problems
>> (not just this one).
>>
>> In Terminal, type 'echo $PATH' and examine what it returns. If it
>> doesn't start with /usr/bin:, then there's your problem. It's very
>> likely that if it contains anything besides the default system paths,
>> then it probably contains the name of the thing that will remind you
>> why PATH got redefined. You need to locate the offending shell file
>> redefining PATH, and either fix it or remove it.
>>
>> Common startup script file names (where ~ means your home directory)
>> include ~/.login, ~/.bashrc, ~/.bash_login, ~/.bash_profile ~/.cshrc,
>> ~/.xinitrc, ~/.MacOSX/environment.plist, and so on. Type 'ls -la ~' to
>> find these hidden folders and files and inspect them for lines that
>> change PATH.
>>
>> I'd definitely install Xcode 3.2 for OS X 10.6.2 to avoid other issues
>> and ensure that you have the current gcc compilers, but I don't think
>> that will resolve your first issue. FWIW, on 10.6.2 with Xcode 3.2,
>> the gcc alias should point to gcc-3.2, but MATLAB MEX will use an
>> explicit gcc version number, and not use the alias, which is expected
>> behavior.
>>
>> Report back if you are having success, or other issues with MATLAB MEX.
>>
>> Thanks,
>>
>> - Brian
>>
>> Robert wrote:
>> > Hi Brian, since Christian didn't respond I'm going to ask this for
>> him. > I am running OSX 10.6.2, and I have XCode 3.1.2. I'm not sure
>> why I > don't have XCode 3.2, but I'm downloading it now. If I look in
>> > Developer/usr/bin/ there are files named gcc-4.0 and gcc-4.2, as
>> well as > an alias named gcc that's currently pointing to gcc-4.0.
>> > > I just tried typing 'gcc --version' in Terminal, which replies
>> 'gcc: > command not found'. Can you please help? It looks to me like
>> gcc is on > my computer, so why can neither Terminal nor Matlab find it?
>> > > When I run 'mex -setup' in Matlab, I get
>> > 'The options files available for mex are:
>> > > 1: /Applications/MATLAB_R2010a.app/bin/gccopts.sh : Template >
>> Options file for building gcc MEX-files
>> > > 2: /Applications/MATLAB_R2010a.app/bin/mexopts.sh : Template >
>> Options file for building MEX-files via the system ANSI compiler'
>> > > Is this what I should be seeing? All I want to do is run a program
>> i > downloaded from Matlab Central that requires calling mex on a .cpp
>> > file. Please help, and sorry if I got any of the technical jargon
>> wrong.
>> > > ~Rob
>> > > > Brian Arnold <Brian.Arnold@mathworks.com> wrote in message >
>> <4B7482E3.2030704@mathworks.com>...
>> >> Hi Christian,
>> >>
>> >> Are you sure you installed Xcode developer tools? The installer is
>> on >> your Mac OS X install DVD. Do you have a folder named
>> "Developer" on >> your local hard drive? If you open Terminal, and
>> type 'gcc --version' >> what is returned? If Terminal can't find gcc
>> either, then the tools >> are not installed.
>> >>
>> >> If you need more help than this, please troubleshoot (Google might
>> >> help) and provide more details.
>> >>
>> >> - Brian
>> >>
>> >> Christian wrote:
>> >> > Hello,
>> >> > > I'm trying to setup a mex compiler for MATLAB R2009b (64bit),
>> >> running on > a Mac Intel 64bit, OS X 10.6 and the newest version of
>> >> Apple XCode (3.2.1).
>> >> > I've run mex -setup, but MATLAB cannot locate the g++/gcc
>> compiler. >> Is > there any general walkthrough for setting up the
>> compiler for a >> 64-bit > system?
>> >> > > Thanks,
>> >> > -Christian
>
>
> Hi Brian, Rob and anyone else in this feed.
>
> I'm also struggling changing the default compiler. I've recently
> installed Xcode 3.2. (Its present in the Developer folder). I have gcc
> ver 4.2.1 but matlab still only gives me the two options when I run mex
> -setup.
>
> 1: /Applications/MATLAB_R2010a.app/bin/gccopts.sh : Template Options
> file for building gcc MEX-files
>
> 2: /Applications/MATLAB_R2010a.app/bin/mexopts.sh : Template Options
> file for building MEX-files via the system ANSI compiler'
>
> Any advice?
> Thanks,
> Remus

Subject: MEX Setup for Mac OS X 10.6

From: Alberto Luviano

Date: 2 Oct, 2011 23:14:13

Message: 10 of 14

Hi Brian,

I have a similar problem as Remus. I have a mac os x lion and a matlab 2008b 32bits. When I type gcc --version, the terminal displays

bash-3.2# gcc --version
i686-apple-darwin11-llvm-gcc-4.2 (GCC) 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2335.15.00)
Copyright (C) 2007 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.


However, the mex -setup command displays as follows

 mex -setup

    Options files control which compiler to use, the compiler and link command
    options, and the runtime libraries to link against.

    Using the 'mex -setup' command selects an options file that is
    placed in ~/.matlab/R2008b and used by default for 'mex'. An options
    file in the current working directory or specified on the command line
    overrides the default options file in ~/.matlab/R2008b.
 
    To override the default options file, use the 'mex -f' command
    (see 'mex -help' for more information).

The options files available for mex are:

  1: /Applications/MATLAB_R2008b.app/bin/f90opts.sh :
      Template Options file for building Fortran 90 MEX-files via the system ANSI compiler
 
  2: /Applications/MATLAB_R2008b.app/bin/gccopts.sh :
      Template Options file for building gcc MEX-files
 
  3: /Applications/MATLAB_R2008b.app/bin/mexopts.sh :
      Template Options file for building MEX-files via the system ANSI compiler
 

  0: Exit with no changes

Enter the number of the compiler (0-3):

I do not know how to compile the files because I do not know how to include de gcc compiler in the option list of the mex --setup, or what to do instead. I had installed the Xcode 4.

Thank you so much.

Alberto

Subject: MEX Setup for Mac OS X 10.6

From: Steven_Lord

Date: 3 Oct, 2011 02:32:46

Message: 11 of 14



"Alberto Luviano" <alberto.luviano@gmail.com> wrote in message
news:j6ar85$4ro$1@newscl01ah.mathworks.com...
> Hi Brian,
>
> I have a similar problem as Remus. I have a mac os x lion and a matlab
> 2008b 32bits. When I type gcc --version, the terminal displays

Lion (OS X 10.7) is not an officially supported OS for release R2008b.

http://www.mathworks.com/support/sysreq/release2008b/macintosh.html

Release R2011a and later are officially supported on Lion.

http://www.mathworks.com/support/sysreq/release2011a/macintosh.html

*snip*

> However, the mex -setup command displays as follows
> mex -setup

*snip*

For release R2008b, the supported compiler names and versions are given
here:

http://www.mathworks.com/support/compilers/release2008b/macintosh.html

--
Steve Lord
slord@mathworks.com
To contact Technical Support use the Contact Us link on
http://www.mathworks.com

Subject: MEX Setup for Mac OS X 10.6

From: Alberto Luviano

Date: 3 Oct, 2011 03:40:31

Message: 12 of 14

Hi Steven:

Thank you for your response. In particular, we are trying to use the ellipsoidal toolbox (Alex Kurzhanskiy). Is this toolbox supported in the 2011a release (32 or 64 bits)?

Best regards!

Alberto.



"Steven_Lord" <slord@mathworks.com> wrote in message <j6b6sd$7te$1@newscl01ah.mathworks.com>...
>
>
> "Alberto Luviano" <alberto.luviano@gmail.com> wrote in message
> news:j6ar85$4ro$1@newscl01ah.mathworks.com...
> > Hi Brian,
> >
> > I have a similar problem as Remus. I have a mac os x lion and a matlab
> > 2008b 32bits. When I type gcc --version, the terminal displays
>
> Lion (OS X 10.7) is not an officially supported OS for release R2008b.
>
> http://www.mathworks.com/support/sysreq/release2008b/macintosh.html
>
> Release R2011a and later are officially supported on Lion.
>
> http://www.mathworks.com/support/sysreq/release2011a/macintosh.html
>
> *snip*
>
> > However, the mex -setup command displays as follows
> > mex -setup
>
> *snip*
>
> For release R2008b, the supported compiler names and versions are given
> here:
>
> http://www.mathworks.com/support/compilers/release2008b/macintosh.html
>
> --
> Steve Lord
> slord@mathworks.com
> To contact Technical Support use the Contact Us link on
> http://www.mathworks.com

Subject: MEX Setup for Mac OS X 10.6

From: Steven_Lord

Date: 3 Oct, 2011 13:21:12

Message: 13 of 14



"Alberto Luviano" <alberto.luviano@gmail.com> wrote in message
news:j6barf$k17$1@newscl01ah.mathworks.com...
> Hi Steven:
>
> Thank you for your response. In particular, we are trying to use the
> ellipsoidal toolbox (Alex Kurzhanskiy). Is this toolbox supported in the
> 2011a release (32 or 64 bits)?

Since that's not a toolbox provided by MathWorks, you'd need to ask the
author if it's supported on a particular release/platform combination or
simply try it and contact the author for help with any problems.

--
Steve Lord
slord@mathworks.com
To contact Technical Support use the Contact Us link on
http://www.mathworks.com

Subject: MEX Setup for Mac OS X 10.6

From: Robert

Date: 5 Oct, 2011 17:21:27

Message: 14 of 14

Hi, I didn't read through this entire thread so I apologize if this is already settled, but I was having a similar problem and fixed it very easily. See here:
http://www.mathworks.com/matlabcentral/answers/14222-mex-can-t-find-gcc-in-path

Tags for this Thread

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us