I'm using Matlab Coder in Matlab-r2014b in OS X 10.9.5. I have Xcode 6.2. I'm unable to generate a Mex function using Matlab compiler. I'm reporting here a sample code with structure and type of variables similar to my real one.
1) The script that calls the entry-point
clear all N=3 ; Res=alg(N);
2) The entry-point
function val=alg(N)%#codegen
coder.inline('never')coder.varsize('matrixfinal');matrixfinal=zeros(1,3*N+2); profindex=randi(N+1,2^(N-1),1);for s=1:10coder.varsize('matrix');matrix=zeros(1,3*N+2);for k=1:2^(N-1) if profindex(k)==N-1 matrix=[(matrix); randi(1,1,3*N+2)]; endendif size(matrix,1)>1 matrix(1,:)=[];endfor k=1:size(matrix,1) for h=1:size(matrixfinal,1) if sum(matrix(k,2+2*N:3*N)==matrixfinal(h,2+2*N:3*N))==N-1 matrixfinal(h,3*N+1)=matrixfinal(h,3*N+1)+matrix(k,3*N+1); matrixfinal(h,3*N+2)=matrixfinal(h,3*N+2)+matrix(k,3*N+2); end endendendif size(matrixfinal,1)>1 matrixfinal(1,:)=[];endval=matrixfinal(1,1); end
When I try to built the Mex Function I get the following error
??? Build error: Compilation returned error status code 2. See the target build log in the report for further details.Error in ==> alg Line: 1 Column: 1Code generation failed: Open error report.
If I open error report, I read
1 xcrun -sdk macosx10.7 clang -c -fno-common -arch x86_64 -isysroot -mmacosx-version-min=10.7 -fexceptions -DMX_COMPAT_32 -O2 -DNDEBUG -I ".... 2 xcodebuild: error: SDK "macosx10.7" cannot be located. 3 xcrun: error: unable to find utility "clang", not a developer tool or in PATH 4 gmake: *** [alg_mexutil.o] Error 72
How can I solve this problem? If instead I generate C/C++ Static Library it works. I found these instructions http://www.mathworks.com/matlabcentral/answers/103904-can-i-use-xcode-5-as-my-c-or-c-compiler-in-matlab-8-1-r2013a-or-matlab-8-2-r2013b but they are for 10.8
Thanks for your help
Best Answer