Mex function with OS X 10.9.5 and Xcode 6.2? - xcode

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)
profindex=randi(N+1,2^(N-1),1);
for s=1:10
coder.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)];
end
end
if size(matrix,1)>1
matrix(1,:)=[];
end
for 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
end
end
end
if size(matrixfinal,1)>1
matrixfinal(1,:)=[];
end
val=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: 1 Code generation failed: Open error report.
If I open error report, It reads
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
I found these instructions but they are for 10.8 and if I replace 10.8 with 10.9.5 it does not work and I get always the same errors and in the following order
SDK "macosx10.7" cannot be located
SDK "macosx10.8" cannot be located
SDK "macosx10.9.5" cannot be located.
How to fix these errors?

Related

Parallel compilation giving problem in MSYS2

When I am compiling with J8, sometime I am getting the following error:
C:\msys64\usr\bin\make.exe -C firmware all -j8 -O
Compiling file: project/src/tests.c with optimization level: -Os
error: unable to open output file 'build/tests.o': 'no such file or directory'
1 error generated.
This happens randomly.
If I change J8 to J1, then compilation is always successful. There is no problem with path or directory permission as compilation is working with J1 and sometime with J8.
My setup details:
MSYS2
ARM Compiler v6.16
Windows 10
Not sure whether it is a problem of MSYS2 or ARM Compiler or Window specific problem.

gcc compiling errors using macOS BigSur M1 chip

I recently switched from Windows to mac and bravely took the new MacBook with macOS BigSur and M1 chip. I'm trying to install BPP (https://github.com/bpp/bpp) following the program's installation guide, but run into problems when trying to compile an executable file.
git clone https://github.com/bpp/bpp.git
cd bpp/src
make
This gave multiple errors like this:
cc -D_GNU_SOURCE -DHAVE_SSE3 -DHAVE_AVX -DHAVE_AVX2 -g -msse3 -O3 -Wall -Wsign-compare -c -o bpp.o bpp.c
clang: warning: argument unused during compilation: '-msse3' [-Wunused-command-line-argument]
In file included from bpp.c:22:
In file included from ./bpp.h:43:
In file included from /Library/Developer/CommandLineTools/usr/lib/clang/12.0.0/include/x86intrin.h:15:
In file included from /Library/Developer/CommandLineTools/usr/lib/clang/12.0.0/include/immintrin.h:14:
Library/Developer/CommandLineTools/usr/lib/clang/12.0.0/include/mmintrin.h:373:12: error:
invalid conversion between vector type '__m64' (vector of 1 'long long'
value) and integer type 'int' of different size
return (__m64)__builtin_ia32_paddw((__v4hi)__m1, (__v4hi)__m2);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
So I thought maybe the problem is that the default compiler is Clang 12 and after installing gcc-11 (which should be appropriate for M1) run:
make CC=/opt/homebrew/bin/gcc-11
But it gave an error too:
gcc-11: error: unrecognized command-line option '-msse3'
make: *** [bpp.o] Error 1
Since I'm not an experienced coder and with M1 being so new that finding solutions from forums is not simple, I'm kind of in a dead end. Any suggestions how to work through this problem?
I guess it is due to the fact that SSE3 is an x86 feature?

ld: library not found for -llibopencv_dnn.3.3.1.dylib

Getting “ld: library not found for -llibopencv_dnn.3.3.1.dylib:
11:27:44: Running steps for project Hello_OpenCV...
11:27:44: Configuration unchanged, skipping qmake step.
11:27:44: Starting: "/usr/bin/make"
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++ -stdlib=libc++ -headerpad_max_install_names -arch x86_64 -Wl,-syslibroot,/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.13.sdk -mmacosx-version-min=10.10 -Wl,-rpath,#executable_path/Frameworks -o Hello_OpenCV main.o -L/usr/local/lib -llibopencv_dnn.3.3.1.dylib -llibopencv_ml.3.3.1.dylib -llibopencv_objdetect.3.3.1.dylib -llibopencv_shape.3.3.1.dylib -llibopencv_stitching.3.3.1.dylib -llibopencv_superres.3.3.1.dylib -llibopencv_videostab.3.3.1.dylib -llibopencv_calib3d.3.3.1.dylib -llibopencv_features2d.3.3.1.dylib -llibopencv_highgui.3.3.1.dylib -llibopencv_videoio.3.3.1.dylib -llibopencv_imgcodecs.3.3.1.dylib -llibopencv_video.3.3.1.dylib -llibopencv_photo.3.3.1.dylib -llibopencv_imgproc.3.3.1.dylib -llibopencv_flann.3.3.1.dylib -llibopencv_core.3.3.1.dylib
ld: library not found for -llibopencv_dnn.3.3.1.dylib
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [Hello_OpenCV] Error 1
11:27:44: The process "/usr/bin/make" exited with code 2.
Error while building/deploying project Hello_OpenCV (kit: Desktop Qt 5.9.0 clang 64bit)
When executing step "Make"
11:27:44: Elapsed time: 00:00.
Do you actually have OpenCV installed on your system? If you run the following command, do you get any output?
find / -name "*libopencv*" 2>/dev/null
If not, you probably need to ensure you install it first. Follow instructions such as the ones found here.
If the above does return something (example: /path/to/lib/libopencv_dnn.3.3.1dylib), then try adding -L/path/to/lib into your compile line
It looks like you're including the entire suite of OpenCV modules, some of which are very feature-specific and likely not needed if you have a simple application. The DNN module in particular is not included in binary form with OpenCV (see this page on the matter). If you're sure you need it, you need to compile it yourself.
If you aren't doing any machine learning, you likely don't need the library and you can remove -llibopencv_dnn.3.3.1.dylib from your compile line.

GODI-Batteries: Installation problems

I am trying to install godi-batteries using GODI console. I seem to have all dependencies sorted (like Camomile). I get the following error within Godi's interface:
> ocamlfind ocamlopt -shared -linkall -package camomile,num,str -o src/batteries_uni.cmxs src/batteries_uni.cmxa
> + ocamlfind ocamlopt -shared -linkall -package camomile,num,str -o src/batteries_uni.cmxs src/batteries_uni.cmxa
> ld: warning: -read_only_relocs cannot be used with x86_64
> ld: codegen problem, can't use rel32 to external symbol _caml_negf_mask in .L101 from src/batteries_uni.a(batFloat.o)
> collect2: ld returned 1 exit status
> File "caml_startup", line 1, characters 0-1:
> Error: Error during linking
> Command exited with code 2.
> make[7]: *** [all] Error 10
> Error: Exec error: File /Users/surikator/godi/build/godi/godi-batteries/./../../mk/bsd.pkg.mk, line 1039: Command returned with non-zero exit code
> Error: Exec error: File /Users/surikator/godi/build/godi/godi-batteries/./../../mk/bsd.pkg.mk, line 1378: Command returned with non-zero exit code
I'm using Mac OS X 10.6.4. and I have a 64 bit machine.
Any ideas on how to go around this?
Thanks,
Surikator.
For some reason, OSX OCaml can't build shared libraries. You'll have to disable batteries' building of shared libraries with
BATTERIES_NATIVE_SHLIB=no make
This problem has been fixed in git commit 92b323, and will be included in the next release.

CMake/GCC "unrecognized option" on Mac OS X

I'm trying to create a project as a shared library in OS X using CMake 2.8 and gcc 4.6 (from macports). When CMake gets to the point of linking my library into a .dylib, I get the following error from gcc:
g++ -dynamiclib -headerpad_max_install_names -o libmycoollibrary.dylib etc...
g++: error: unrecognized option '-h'
make[2]: *** [libnrtCore.dylib] Error 1
make[1]: *** [CMakeFiles/nrtCore.dir/all] Error 2
make: *** [all] Error 2
This -headerpad_max_install_names seems to be the problem, but I've never seen it before. Does anyone know how to either get CMake to not include this option, or to get GCC to accept this option?
You can re-build cmake to fix this -- it's apparently generating code for the XCode / Darwin version of g++ (a special version of 4.2), which accepts a number of non-standard linker flags.
Just change the Modules/Platform/Darwin*.cmake files and re-build. The culprit lines look like this:
SET(CMAKE_CXX_LINK_FLAGS "-Wl,-search_paths_first -headerpad_max_install_names")

Resources