Using MinGW compiler and Open MP

6 ビュー (過去 30 日間)
Øyvind
Øyvind 2016 年 4 月 15 日
コメント済み: Rik 2022 年 6 月 13 日
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 件のコメント
Øyvind
Øyvind 2016 年 4 月 20 日
The experiment worked! Thanks a lot.
Rik
Rik 2022 年 6 月 13 日
Comment posted as flag by Ming ZHANG:
Thank you so much, it works!

サインインしてコメントする。

回答 (1 件)

Jeppe Druedahl
Jeppe Druedahl 2016 年 4 月 19 日
編集済み: Jeppe Druedahl 2016 年 4 月 19 日
I have found a somewhat odd solution.
1. Install TDM-GCC independently from http://tdm-gcc.tdragon.net/ (I installed 5.1.0)
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
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
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!

Translated by