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:
Issues when using mex with 2011b in Mac OSX 10.7.3

Subject: Issues when using mex with 2011b in Mac OSX 10.7.3

From: David Parsons

Date: 26 Feb, 2012 17:27:14

Message: 1 of 12

Hi,

I am having issues when attempting to compile the mex file in Mac (osx 10.7.3). I have downloaded Xcode 4.3 and have used the patch for 2011b (http://www.mathworks.com/support/solutions/en/data/1-FR6LXJ/). Which has gotten me beyond the initial error of:

/Applications/MATLAB_R2011b.app/bin/mex: line 305: gcc-4.2: command not found

However, now I have the new issue of:

mex yprime.c
yprime.c:17:18: error: math.h: No such file or directory
In file included from /usr/llvm-gcc-4.2/bin/../lib/gcc/i686-apple-darwin11/4.2.1/include/limits.h:15,
                 from /Applications/MATLAB_R2011b.app/extern/include/tmwtypes.h:43,
                 from /Applications/MATLAB_R2011b.app/extern/include/matrix.h:294,
                 from /Applications/MATLAB_R2011b.app/extern/include/mex.h:58,
                 from yprime.c:18:
/Applications/Xcode.app/Contents/Developer/usr/llvm-gcc-4.2/lib/gcc/i686-apple-darwin11/4.2.1/include/limits.h:15:25: error: no include path in which to search for limits.h
In file included from /Applications/MATLAB_R2011b.app/extern/include/mex.h:58,
                 from yprime.c:18:
/Applications/MATLAB_R2011b.app/extern/include/matrix.h:851:20: error: stdlib.h: No such file or directory
In file included from yprime.c:18:
/Applications/MATLAB_R2011b.app/extern/include/mex.h:161:19: error: stdio.h: No such file or directory
yprime.c: In function 'yprime':
yprime.c:52: warning: incompatible implicit declaration of built-in function 'sqrt'

    mex: compile of ' "yprime.c"' failed.


This is completely out of my level of expertise and have no idea what is going on. Any help would be greatly appreciated.

Cheers,
Dave

Subject: Issues when using mex with 2011b in Mac OSX 10.7.3

From: Brian Arnold

Date: 27 Feb, 2012 16:07:43

Message: 2 of 12

Hi David,

Header files are usually found through the specified SDK. I will guess
that because you are using Xcode 4.3, that the 10.6 SDK specified by the
R2011b mexopts.sh file is not being found, and is then leading to the
errors you are seeing.

As a possible workaround, try creating a copy of the mexopts.sh file and
change the specified SDK from 10.6 to 10.7.

I'll follow up internally regarding what to change in the support solution.

Thanks,

Brian

On 2/26/12 12:27 PM, David Parsons wrote:
> Hi,
>
> I am having issues when attempting to compile the mex file in Mac (osx
> 10.7.3). I have downloaded Xcode 4.3 and have used the patch for 2011b
> (http://www.mathworks.com/support/solutions/en/data/1-FR6LXJ/). Which
> has gotten me beyond the initial error of:
>
> /Applications/MATLAB_R2011b.app/bin/mex: line 305: gcc-4.2: command not
> found
>
> However, now I have the new issue of:
>
> mex yprime.c
> yprime.c:17:18: error: math.h: No such file or directory
> In file included from
> /usr/llvm-gcc-4.2/bin/../lib/gcc/i686-apple-darwin11/4.2.1/include/limits.h:15,
>
> from /Applications/MATLAB_R2011b.app/extern/include/tmwtypes.h:43,
> from /Applications/MATLAB_R2011b.app/extern/include/matrix.h:294,
> from /Applications/MATLAB_R2011b.app/extern/include/mex.h:58,
> from yprime.c:18:
> /Applications/Xcode.app/Contents/Developer/usr/llvm-gcc-4.2/lib/gcc/i686-apple-darwin11/4.2.1/include/limits.h:15:25:
> error: no include path in which to search for limits.h
> In file included from
> /Applications/MATLAB_R2011b.app/extern/include/mex.h:58,
> from yprime.c:18:
> /Applications/MATLAB_R2011b.app/extern/include/matrix.h:851:20: error:
> stdlib.h: No such file or directory
> In file included from yprime.c:18:
> /Applications/MATLAB_R2011b.app/extern/include/mex.h:161:19: error:
> stdio.h: No such file or directory
> yprime.c: In function 'yprime':
> yprime.c:52: warning: incompatible implicit declaration of built-in
> function 'sqrt'
>
> mex: compile of ' "yprime.c"' failed.
>
>
> This is completely out of my level of expertise and have no idea what is
> going on. Any help would be greatly appreciated.
> Cheers,
> Dave

Subject: Issues when using mex with 2011b in Mac OSX 10.7.3

From: David Parsons

Date: 27 Feb, 2012 16:38:11

Message: 3 of 12

Hi Brian,

I did try that as recommended by L R in a previous thread for an older version of Matlab and Mac OSX (http://www.mathworks.com/matlabcentral/newsreader/view_thread/304392).

This is the mexopts.sh that I was using:

        maci64)
#----------------------------------------------------------------------------
            # StorageVersion: 1.0
            # CkeyName: GNU C
            # CkeyManufacturer: GNU
            # CkeyLanguage: C
            # CkeyVersion:
            CC='llvm-gcc-4.2'
            SDKROOT='/Developer/SDKs/MacOSX10.7.sdk'
            MACOSX_DEPLOYMENT_TARGET='10.5'
            ARCHS='x86_64'
            CFLAGS="-fno-common -no-cpp-precomp -arch $ARCHS -isysroot $SDKROOT -mmacosx-version-min=$MACOSX_DEPLOYMENT_TARGET"
            CFLAGS="$CFLAGS -fexceptions"
            CLIBS="$MLIBS"
            COPTIMFLAGS='-O2 -DNDEBUG'
            CDEBUGFLAGS='-g'
#

Cheers,
Dave



Brian Arnold <Brian.Arnold@mathworks.com> wrote in message <4F4BAA4F.2060201@mathworks.com>...
> Hi David,
>
> Header files are usually found through the specified SDK. I will guess
> that because you are using Xcode 4.3, that the 10.6 SDK specified by the
> R2011b mexopts.sh file is not being found, and is then leading to the
> errors you are seeing.
>
> As a possible workaround, try creating a copy of the mexopts.sh file and
> change the specified SDK from 10.6 to 10.7.
>
> I'll follow up internally regarding what to change in the support solution.
>
> Thanks,
>
> Brian
>

Subject: Issues when using mex with 2011b in Mac OSX 10.7.3

From: Brian Arnold

Date: 27 Feb, 2012 19:55:21

Message: 4 of 12

Hi David,

What happens if you also change the MACOSX_DEPLOYMENT_TARGET to 10.7?

Brian

On 2/27/12 11:38 AM, David Parsons wrote:
> Hi Brian,
>
> I did try that as recommended by L R in a previous thread for an older
> version of Matlab and Mac OSX
> (http://www.mathworks.com/matlabcentral/newsreader/view_thread/304392).
>
> This is the mexopts.sh that I was using:
>
> maci64)
> #----------------------------------------------------------------------------
>
> # StorageVersion: 1.0
> # CkeyName: GNU C
> # CkeyManufacturer: GNU
> # CkeyLanguage: C
> # CkeyVersion:
> CC='llvm-gcc-4.2'
> SDKROOT='/Developer/SDKs/MacOSX10.7.sdk'
> MACOSX_DEPLOYMENT_TARGET='10.5'
> ARCHS='x86_64'
> CFLAGS="-fno-common -no-cpp-precomp -arch $ARCHS -isysroot $SDKROOT
> -mmacosx-version-min=$MACOSX_DEPLOYMENT_TARGET"
> CFLAGS="$CFLAGS -fexceptions"
> CLIBS="$MLIBS"
> COPTIMFLAGS='-O2 -DNDEBUG'
> CDEBUGFLAGS='-g'
> #
>
> Cheers,
> Dave
>
>
>
> Brian Arnold <Brian.Arnold@mathworks.com> wrote in message
> <4F4BAA4F.2060201@mathworks.com>...
>> Hi David,
>>
>> Header files are usually found through the specified SDK. I will guess
>> that because you are using Xcode 4.3, that the 10.6 SDK specified by
>> the R2011b mexopts.sh file is not being found, and is then leading to
>> the errors you are seeing.
>>
>> As a possible workaround, try creating a copy of the mexopts.sh file
>> and change the specified SDK from 10.6 to 10.7.
>>
>> I'll follow up internally regarding what to change in the support
>> solution.
>>
>> Thanks,
>>
>> Brian
>>

Subject: Issues when using mex with 2011b in Mac OSX 10.7.3

From: David Parsons

Date: 27 Feb, 2012 20:14:13

Message: 5 of 12

Hi Brian,

I get the same output as I listed in my original post.

Dave


Brian Arnold <Brian.Arnold@mathworks.com> wrote in message <4F4BDFA9.9040902@mathworks.com>...
> Hi David,
>
> What happens if you also change the MACOSX_DEPLOYMENT_TARGET to 10.7?
>
> Brian
>

Subject: Issues when using mex with 2011b in Mac OSX 10.7.3

From: Xiangmin (Jim) Jiao

Date: 1 Mar, 2012 05:28:41

Message: 6 of 12


I had a similar issue when using Xcode 4.3. The reason is that Xcode 4.3 does not create the /Developer directory. Instead, all the header files are under /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/

The fix is the following.

1. Run command
mex -setup
in MATLAB.

It would create a file
/Users/MyUserName/.matlab/R2011b/mexopts.sh

2. Then edit
/Users/MyUserName/.matlab/R2011b/mexopts.sh
(You could edit /Applications/MATLAB_R2011b.app/bin/mexopts.sh directly, but I did not want to mess with MATLAB's default mexopts.sh file.)

and change line 167 from
            SDKROOT='/Developer/SDKs/MacOSX10.6.sdk/'
to
            SDKROOT='/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.7.sdk/'

Then everything should work fine.

-Jim

"David Parsons" <junkfoldermatlab@hotmail.com> wrote in message <jigo6k$64j$1@newscl01ah.mathworks.com>...
> Hi Brian,
>
> I get the same output as I listed in my original post.
>
> Dave
>
>
> Brian Arnold <Brian.Arnold@mathworks.com> wrote in message <4F4BDFA9.9040902@mathworks.com>...
> > Hi David,
> >
> > What happens if you also change the MACOSX_DEPLOYMENT_TARGET to 10.7?
> >
> > Brian
> >

Subject: Issues when using mex with 2011b in Mac OSX 10.7.3

From: David Parsons

Date: 1 Mar, 2012 11:54:14

Message: 7 of 12

Awesome, that worked like a charm!! Thank you Jim, now my reconstruction absolutely flys lol.

Cheers,
Dave

"Xiangmin (Jim) Jiao" wrote in message <jin1e9$7q2$1@newscl01ah.mathworks.com>...
>
> I had a similar issue when using Xcode 4.3. The reason is that Xcode 4.3 does not create the /Developer directory. Instead, all the header files are under /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/
>
> The fix is the following.
>
> 1. Run command
> mex -setup
> in MATLAB.
>
> It would create a file
> /Users/MyUserName/.matlab/R2011b/mexopts.sh
>
> 2. Then edit
> /Users/MyUserName/.matlab/R2011b/mexopts.sh
> (You could edit /Applications/MATLAB_R2011b.app/bin/mexopts.sh directly, but I did not want to mess with MATLAB's default mexopts.sh file.)
>
> and change line 167 from
> SDKROOT='/Developer/SDKs/MacOSX10.6.sdk/'
> to
> SDKROOT='/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.7.sdk/'
>
> Then everything should work fine.
>
> -Jim
>

Subject: Issues when using mex with 2011b in Mac OSX 10.7.3

From: Eric Diaz

Date: 17 Mar, 2012 04:10:19

Message: 8 of 12

I had the same problem and had tried the same solutions with no resolution, until I found this thread. This solution worked! Thanks!

Subject: Issues when using mex with 2011b in Mac OSX 10.7.3

From: Ronny

Date: 4 Apr, 2012 17:06:12

Message: 9 of 12

"Eric Diaz" wrote in message <jk12rb$s5u$1@newscl01ah.mathworks.com>...
> I had the same problem and had tried the same solutions with no resolution, until I found this thread. This solution worked! Thanks!

Subject: Issues when using mex with 2011b in Mac OSX 10.7.3

From: Hugo Dupuis

Date: 10 May, 2012 01:44:12

Message: 10 of 12

You saved hours of my life !

Thanks

"David Parsons" <junkfoldermatlab@hotmail.com> wrote in message <jino16$chn$1@newscl01ah.mathworks.com>...
> Awesome, that worked like a charm!! Thank you Jim, now my reconstruction absolutely flys lol.
>
> Cheers,
> Dave
>
> "Xiangmin (Jim) Jiao" wrote in message <jin1e9$7q2$1@newscl01ah.mathworks.com>...
> >
> > I had a similar issue when using Xcode 4.3. The reason is that Xcode 4.3 does not create the /Developer directory. Instead, all the header files are under /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/
> >
> > The fix is the following.
> >
> > 1. Run command
> > mex -setup
> > in MATLAB.
> >
> > It would create a file
> > /Users/MyUserName/.matlab/R2011b/mexopts.sh
> >
> > 2. Then edit
> > /Users/MyUserName/.matlab/R2011b/mexopts.sh
> > (You could edit /Applications/MATLAB_R2011b.app/bin/mexopts.sh directly, but I did not want to mess with MATLAB's default mexopts.sh file.)
> >
> > and change line 167 from
> > SDKROOT='/Developer/SDKs/MacOSX10.6.sdk/'
> > to
> > SDKROOT='/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.7.sdk/'
> >
> > Then everything should work fine.
> >
> > -Jim
> >

Subject: Issues when using mex with 2011b in Mac OSX 10.7.3

From: yoni klein

Date: 25 Jul, 2012 09:06:08

Message: 11 of 12

Hi Jim,
I have the same problem and when i tried to use your solution i had several problems:
1. i couldn't find the path "/Users/MyUserName/.matlab/R2011b/mexopts.sh" only the main path that you said.
2. i couldn't find the line that you refferd to. i don't have "SDKROOT" in my file.

what can i do?

i think i don't have xcode also.

thanks

Yoni.



"Xiangmin (Jim) Jiao" wrote in message <jin1e9$7q2$1@newscl01ah.mathworks.com>...
>
> I had a similar issue when using Xcode 4.3. The reason is that Xcode 4.3 does not create the /Developer directory. Instead, all the header files are under /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/
>
> The fix is the following.
>
> 1. Run command
> mex -setup
> in MATLAB.
>
> It would create a file
> /Users/MyUserName/.matlab/R2011b/mexopts.sh
>
> 2. Then edit
> /Users/MyUserName/.matlab/R2011b/mexopts.sh
> (You could edit /Applications/MATLAB_R2011b.app/bin/mexopts.sh directly, but I did not want to mess with MATLAB's default mexopts.sh file.)
>
> and change line 167 from
> SDKROOT='/Developer/SDKs/MacOSX10.6.sdk/'
> to
> SDKROOT='/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.7.sdk/'
>
> Then everything should work fine.
>
> -Jim
>
> "David Parsons" <junkfoldermatlab@hotmail.com> wrote in message <jigo6k$64j$1@newscl01ah.mathworks.com>...
> > Hi Brian,
> >
> > I get the same output as I listed in my original post.
> >
> > Dave
> >
> >
> > Brian Arnold <Brian.Arnold@mathworks.com> wrote in message <4F4BDFA9.9040902@mathworks.com>...
> > > Hi David,
> > >
> > > What happens if you also change the MACOSX_DEPLOYMENT_TARGET to 10.7?
> > >
> > > Brian
> > >

Subject: Issues when using mex with 2011b in Mac OSX 10.7.3

From: Anders Munk-Nielsen

Date: 12 Feb, 2013 21:42:17

Message: 12 of 12

Jim, you're a life-saver! It worked perfectly for me as well. I should note that I installed Xcode and then the command-line tools (from under Xcode preferences -> Downloads). Check that it's properly installed by typing "llvm" and double-tabbing in a terminal to look at the autocomplete options and make sure that the llvm-gcc and variants are there.

Anders

"Xiangmin (Jim) Jiao" wrote in message <jin1e9$7q2$1@newscl01ah.mathworks.com>...
>
> I had a similar issue when using Xcode 4.3. The reason is that Xcode 4.3 does not create the /Developer directory. Instead, all the header files are under /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/
>
> The fix is the following.
>
> 1. Run command
> mex -setup
> in MATLAB.
>
> It would create a file
> /Users/MyUserName/.matlab/R2011b/mexopts.sh
>
> 2. Then edit
> /Users/MyUserName/.matlab/R2011b/mexopts.sh
> (You could edit /Applications/MATLAB_R2011b.app/bin/mexopts.sh directly, but I did not want to mess with MATLAB's default mexopts.sh file.)
>
> and change line 167 from
> SDKROOT='/Developer/SDKs/MacOSX10.6.sdk/'
> to
> SDKROOT='/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.7.sdk/'
>
> Then everything should work fine.
>
> -Jim
>
> "David Parsons" <junkfoldermatlab@hotmail.com> wrote in message <jigo6k$64j$1@newscl01ah.mathworks.com>...
> > Hi Brian,
> >
> > I get the same output as I listed in my original post.
> >
> > Dave
> >
> >
> > Brian Arnold <Brian.Arnold@mathworks.com> wrote in message <4F4BDFA9.9040902@mathworks.com>...
> > > Hi David,
> > >
> > > What happens if you also change the MACOSX_DEPLOYMENT_TARGET to 10.7?
> > >
> > > Brian
> > >

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