Using MinGW compiler and Open MP
5 views (last 30 days)
Show older comments
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 Comments
Answers (1)
Jeppe Druedahl
on 19 Apr 2016
Edited: Jeppe Druedahl
on 19 Apr 2016
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 Comments
Peter Schober
on 10 Mar 2018
Edited: Peter Schober
on 10 Mar 2018
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
on 11 Sep 2020
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'
See Also
Categories
Find more on MATLAB Support for MinGW-w64 C/C++ Compiler in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!