0

I'm trying to setup mex with Matlab R2013a on my Mac. The following are the compilers I have on the machine (through Xcode I believe). How can I update the compiler and configure the mex setup?

fadama:[~]$ gcc --version
Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-   include-dir=/usr/include/c++/4.2.1
Apple LLVM version 5.1 (clang-503.0.40) (based on LLVM 3.4svn)
Target: x86_64-apple-darwin12.5.0
Thread model: posix
fadama:[~]$ llvm-gcc --version
i686-apple-darwin11-llvm-gcc-4.2 (GCC) 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2336.11.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.

I was able to finally setup the mex.

When I try compiling the sample code from "Accelerating Matlab with GPUs. A Primer with Examples", I get the following errors:

>> system('nvcc -c AddVectors.cu')
clang: error: unsupported option '-dumpspecs'
clang: error: no input files

ans =

     1

Please help. I'm on a Mac with updated Xcode.

Thank you in advance.

kirikoumath
  • 723
  • 9
  • 20
  • Run `mex -setup` at the MATLAB command line and pick one of the compilers it finds – Praetorian Jul 07 '14 at 16:07
  • it only gives the option for the mexopts.sh file. No choices for the compiler – kirikoumath Jul 07 '14 at 16:14
  • I only has the `mexopts.sh` as well. I am also running R2013a using Mac OS X Mavericks (10.9.3). Choosing `mexopts.sh` will default to whatever default `clang` compiler you have on your machine. I have the same `gcc` version as you, but my `llvm` is v5.1. As far as I can tell, what you have should be sufficient. I have also chosen just `mexopts.sh`, and I can compile my MEX code just fine. Give your `mex` command a whirl by doing: `copyfile(fullfile(matlabroot,'extern','examples','mex', 'yprime.c'),'.','f'); mex yprime.c`. If your `mex` is setup properly, this should compile `yprime.c`. – rayryeng Jul 07 '14 at 16:41
  • Adding on top of this, if you really want to update the compilers, you'll need to update XCode. – rayryeng Jul 07 '14 at 16:42
  • @user5503 - Check this thread out: http://stackoverflow.com/questions/19649634/clang-error-unsupported-option-static-libgcc-on-mac-osx-mavericks . `gcc` is not really on Mavericks. It's a copy of `clang` as you have seen in the post you have specified. What you'll have to do is get rid of that `dumpspecs` flag as the `clang` compiler doesn't support that option. You'll have to go into your `mexopts.sh` file and find where this flag is being called.... and remove it. If it's not located in `mexopts.sh`, then it's being called somewhere in our build system.... that I don't know where. – rayryeng Jul 07 '14 at 16:44
  • Just a heads up, you should check out the [supported comilers](http://www.mathworks.com/support/compilers/R2013a/index.html?sec=maci64) for your version of MATLAB. Once you have a supported compiler installed, select it by typing `mex -setup` in the terminal and you should see the compiler listed. By typing `system('nvcc ...')` you aren't using MEX, you're simple calling `nvcc` through the regular terminal through MATLAB. To compile MEX files with cuda support you need to append the correct compiler flags through something like `CFLAGS='$CFLAGS flags'` and also link against libraries. – JustinBlaber Jul 07 '14 at 18:03

0 Answers0