Using MinGW compiler and Open MP
조회 수: 5 (최근 30일)
이전 댓글 표시
I'm using Matlab 2015b and try to create a mex function using the MinGW compiler with OpenMP activated:
mex -setup:'C:\Program Files\MATLAB\R2015b\bin\win64\mexopts\mingw64.xml' C
mex -V CFLAGS="\$CFLAGS -fopenmp" LDFLAGS="\$LDFLAGS -fopenmp" test_openmp_Omp.c
The last call to mex produces the following error message:
Error using mex
gcc: error: \-fexceptions: No such file or directory
-fexceptions is supposed to be a flag to the compiler, but it seems that the \ makes the compiler misinterprete it as a file or directory. Perhaps because of a bug in the mingw64.xml file.
The last part of the output from mex: (seems to be the call to gcc)
Building with 'MinGW64 Compiler (C)'.
C:\TDM-GCC-64\\bin\gcc -c -DMX_COMPAT_32 -DMATLAB_MEX_FILE -I"C:\Program Files\MATLAB\R2015b/extern/include" -I"C:\Program Files\MATLAB\R2015b/simulink/include" -I"C:\Program Files\MATLAB\R2015b/extern\lib\win64\mingw64" \-fexceptions -fno-omit-frame-pointer -fopenmp -fexceptions -O -DNDEBUG \\hca-vnas-h12.res.no.enterdir.com\H12_HOME01\160725\personal\MATLAB\myToolbox\convolution\test_openmp_Omp.c -o C:\Users\160725\AppData\Local\Temp\mex_253195324901869_11764\test_openmp_Omp.obj
Any help would be greatly appreciated.
댓글 수: 3
답변 (1개)
Jeppe Druedahl
2016년 4월 19일
편집: Jeppe Druedahl
2016년 4월 19일
I have found a somewhat odd solution.
2. Link til libgomp.a in that installation when compilling your mex file.
I specifically used:
mex C:\TDM-GCC-64\lib\gcc\x86_64-w64-mingw32\5.1.0\libgomp.a CXXFLAGS="$CXXFLAGS -std=c++11 -fopenmp" test_openmp.cpp
댓글 수: 2
Peter Schober
2018년 3월 10일
편집: Peter Schober
2018년 3월 10일
Thanks, this worked for me. Note: make sure to check openmp under the gcc node when asked to choose components in the installation of TDM.
Clement Val
2020년 9월 11일
Just a quick comment in passing: I also had success linking to the runtime library provided with the MinGW installation included in the MATLAB Support Package.
In my case, the mex command was this:
mex C:\ProgramData\MATLAB\SupportPackages\R2020a\3P.instrset\mingw_w64.instrset\lib\gcc\x86_64-w64-mingw32\6.3.0\libgomp.a -v commonTimePar.c CFLAGS='$CFLAGS -fopenmp' -LDFLAGS='$LDFLAGS -fopenmp'
참고 항목
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!