Compiling Mex files in Mac 10.9

1 view (last 30 days)
Kamil
Kamil on 11 Oct 2014
Answered: psr on 3 Dec 2016
I'm trying to compile a mex file (in OS X 10.9) To be more specific, I'm trying to install the function SVMStruct (from http://www.robots.ox.ac.uk/~vedaldi/code/svm-struct-matlab.html#ssvm.download) but lack of mex command on my mac prevents from doing so. Here is the complete error message after typing
make MEX=/Applications/MATLAB_R2013a.app/bin/mex
/Applications/MATLAB_R2013a.app/bin/mex -largeArrayDims - CFLAGS='$CFLAGS -Wall' LDFLAGS='$LDFLAGS ' -outdir "build//" -c "svm_struct_api.c"
mex: - not a valid option.
Usage:
MEX [option1 ... optionN] sourcefile1 [... sourcefileN]
[objectfile1 ... objectfileN] [libraryfile1 ... libraryfileN]
Use the -help option for more information, or consult the MATLAB External Interfaces Guide.
make: *** [build//svm_struct_api.o] Error 1
And this is the error message I receive when typing
make MEX=/Applications/MATLAB_R2013a.app/bin/mex ARCH=maci64
/Applications/MATLAB_R2013a.app/bin/mex -largeArrayDims -maci64 CFLAGS='$CFLAGS -m64 -isysroot /Developer/SDKs/MacOSX10.6.sdk -mmacosx-version-min=10.4 -Wall' LDFLAGS='$LDFLAGS -mmacosx- version-min=10.4' -outdir "build/maci64/" -c "svm_struct_api.c"
xcrun: error: SDK "macosx10.7" cannot be located
clang: warning: no such sysroot directory: '/Developer/SDKs/MacOSX10.6.sdk'
svm_struct_api.c:20:10: fatal error: 'stdio.h' file not found
#include <stdio.h>
^
1 error generated.
mex: compile of ' "svm_struct_api.c"' failed.
make: *** [build/maci64/svm_struct_api.o] Error 1
The error talks about Mac OS X 10.6 and 10.7 but I'm using 10.9.

Accepted Answer

Geoff Hayes
Geoff Hayes on 11 Oct 2014
Kamil - I observed the same error when running Make (from the terminal window, in the folder /Users/geoff/.../svm-struct-matlab-1.0) as make ARCH=maci64
...
Building with 'Xcode with Clang'.
clang: warning: no such sysroot directory: '/Developer/SDKs/MacOSX10.6.sdk'
/Users/geoff/.../svm-struct-matlab-1.0/svm_struct_api.c:20:10: fatal error: 'stdio.h' file not
found #include <stdio.h>
...
The Makefile has the following lines (of interest)
# Mac OS X Intel 32
ifeq ($(ARCH),maci)
SDKROOT ?= /Developer/SDKs/MacOSX10.6.sdk
This folder doesn't exist on my computer (OS X 10.8.5). Since MEX has been configured to use 'Xcode with Clang', the equivalent SDKs directory is
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs
Within this directory, I have
MacOSX10.8.sdk
MacOSX10.9.sdk
So I changed the line in the Makefile from the
SDKROOT ?= /Developer/SDKs/MacOSX10.6.sdk
to
SDKROOT ?= /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk
and then re-ran make ARCH=maci64 and the svm_struct_learn.mexmaci64 file was built. (Running, in the Command Window of MATLAB, test_svm_struct_learn was successful).
I suggest you try updating the Makefile, in a similar manner as described above, with the appropriate MacOSX10.X.sdk.
  5 Comments
Geoff Hayes
Geoff Hayes on 13 Oct 2014
Perhaps you deleted a single quote from around the '10.8' in the mexopts.sh file. Verify that the modifications you made to the file didn't accidentally remove a quote. i.e. should look like
MACOSX_DEPLOYMENT_TARGET='10.8'
Kamil
Kamil on 14 Oct 2014
You're right, one of the quotes was miswritten. Subsequently, another error appeared
/Applications/MATLAB_R2013a.app/bin/mex -largeArrayDims -maci64 CFLAGS='$CFLAGS -m64 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk -mmacosx-version-min=10.4 -Wall' LDFLAGS='$LDFLAGS -mmacosx-version-min=10.4' -outdir "build/maci64/" -c "svm_struct_api.c"
In file included from svm_struct_api.c:22:
In file included from ./svm_struct/svm_struct_common.h:28:
In file included from ./svm_struct/../svm_light/svm_common.h:22:
In file included from /Applications/MATLAB_R2013a.app/extern/include/mex.h:58:
In file included from /Applications/MATLAB_R2013a.app/extern/include/matrix.h:294:
/Applications/MATLAB_R2013a.app/extern/include/tmwtypes.h:819:9: error: unknown type name 'char16_t'
typedef char16_t CHAR16_T;
^
1 error generated.
mex: compile of ' "svm_struct_api.c"' failed.
make: *** [build/maci64/svm_struct_api.o] Error 1
which was fixed by modifying the file /Applications/MATLAB_R2013a.app/extern/include/tmwtypes.h:
typedef char16_t CHAR16_T;
into
typedef UINT16_T CHAR16_T;
Then finally the file "svm_struct_learn.mexmaci64" was built.

Sign in to comment.

More Answers (1)

psr
psr on 3 Dec 2016
This solution still works for me on Matlab R2015b on MacOSierra

Categories

Find more on Troubleshooting in MATLAB Compiler SDK in Help Center and File Exchange

Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!