MATLAB Answers

mex compiler error with return value of '0'

8 views (last 30 days)
Bryan Munro
Bryan Munro on 29 Apr 2019
Edited: Marko Järvenpää on 31 Jul 2019
I have used the MATLAB MinGW installation tool to install the MinGW compiler but I encounter the following error message when I try to run the basic 'yprime.c' mex example:
mex yprime.c
Building with 'MinGW64 Compiler (C)'.
Error using mex
The command 'C:\ProgramData\MATLAB\SupportPackages\R2019a\3P.instrset\mingw_w64.instrset\bin\gcc' exited with a return value '0'
The compiler seems to be installed correctly and MATLAB clearly has the correct path to the compiler executable but the return value of '0' indicates that MATLAB is calling the compiler with no arguments. This is the mex equivalent of 'hello world' so I'm guessing that something more fundamental is wrong here and I'd appreciate any pointers about what it might be.
I'm running MATLAB 2019a on a Windows 10 machine in admistrator mode so that it can write the appropriate files.
Thanks for the help,
Bryan

  2 Comments

James Tursa
James Tursa on 29 Apr 2019
First thing is to do this in verbose mode. There may be some extra info/insights into what is going on.
mex yprime.c -v
Bryan Munro
Bryan Munro on 29 Apr 2019
James,
Thanks for the quick response; I'm a bit embarassed that I didn't realize there was a verbose mode to run in. I've pasted the outputs below in case something stands out to anyone who might be reading this thread. I'll post an update if I figure things out.
mex yprime.c -v
Verbose mode is on.
... Looking for compiler 'MinGW64 Compiler (C)' ...
... Looking for environment variable 'MW_MINGW64_LOC' ...Yes ('C:\ProgramData\MATLAB\SupportPackages\R2019a\3P.instrset\mingw_w64.instrset').
... Looking for file 'C:\ProgramData\MATLAB\SupportPackages\R2019a\3P.instrset\mingw_w64.instrset\bin\gcc.exe' ...Yes.
... Looking for folder 'C:\ProgramData\MATLAB\SupportPackages\R2019a\3P.instrset\mingw_w64.instrset' ...Yes.
Found installed compiler 'MinGW64 Compiler (C)'.
Set PATH = C:\ProgramData\MATLAB\SupportPackages\R2019a\3P.instrset\mingw_w64.instrset\bin;C:\Program Files\MATLAB\R2019a\extern\include\win64;C:\Program Files\MATLAB\R2019a\extern\include;C:\Program Files\MATLAB\R2019a\simulink\include;C:\Program Files\MATLAB\R2019a\lib\win64;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\Program Files (x86)\Common Files\Oracle\Java\javapath;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Windows\System32\OpenSSH\;C:\Program Files\Intel\WiFi\bin\;C:\Program Files\Common Files\Intel\WirelessCommon\;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files\MATLAB\R2019a\bin;C:\Program Files\MATLAB\R2018b\bin;C:\Program Files (x86)\Windows Kits\8.1\Windows Performance Toolkit\;C:\Users\BryanM\AppData\Local\Microsoft\WindowsApps
Set INCLUDE = C:\ProgramData\MATLAB\SupportPackages\R2019a\3P.instrset\mingw_w64.instrset\include;;
Set LIB = C:\ProgramData\MATLAB\SupportPackages\R2019a\3P.instrset\mingw_w64.instrset\lib;;
Set MW_TARGET_ARCH = win64;
Set LIBPATH = C:\Program Files\MATLAB\R2019a\extern\lib\win64;
Options file details
-------------------------------------------------------------------
Compiler location: C:\ProgramData\MATLAB\SupportPackages\R2019a\3P.instrset\mingw_w64.instrset
Options file: C:\Users\BryanM\AppData\Roaming\MathWorks\MATLAB\R2019a\mex_C_win64.xml
CMDLINE2 : C:\ProgramData\MATLAB\SupportPackages\R2019a\3P.instrset\mingw_w64.instrset\bin\gcc -m64 -Wl,--no-undefined -shared -static -s -Wl,"C:\Program Files\MATLAB\R2019a/extern/lib/win64/mingw64/exportsmexfileversion.def" C:\Users\BryanM\AppData\Local\Temp\mex_84792488536190_15280\yprime.obj C:\Users\BryanM\AppData\Local\Temp\mex_84792488536190_15280\c_mexapi_version.obj -L"C:\Program Files\MATLAB\R2019a\extern\lib\win64\mingw64" -llibmx -llibmex -llibmat -lm -llibmwlapack -llibmwblas -o yprime.mexw64
CC : C:\ProgramData\MATLAB\SupportPackages\R2019a\3P.instrset\mingw_w64.instrset\bin\gcc
COMPILER : C:\ProgramData\MATLAB\SupportPackages\R2019a\3P.instrset\mingw_w64.instrset\bin\gcc
DEFINES : -DMATLAB_DEFAULT_RELEASE=R2017b -DUSE_MEX_CMD -m64 -DMATLAB_MEX_FILE
MATLABMEX : -DMATLAB_MEX_FILE
CFLAGS : -fexceptions -fno-omit-frame-pointer
INCLUDE : -I"C:\Program Files\MATLAB\R2019a/extern/include" -I"C:\Program Files\MATLAB\R2019a/simulink/include" -I"C:\Program Files\MATLAB\R2019a/extern\lib\win64\mingw64"
COPTIMFLAGS : -O2 -fwrapv -DNDEBUG
CDEBUGFLAGS : -g
LD : C:\ProgramData\MATLAB\SupportPackages\R2019a\3P.instrset\mingw_w64.instrset\bin\gcc
LINKER : C:\ProgramData\MATLAB\SupportPackages\R2019a\3P.instrset\mingw_w64.instrset\bin\gcc
LDTYPE : -shared -static
LDFLAGS : -m64 -Wl,--no-undefined
LINKEXPORT : -Wl,"C:\Program Files\MATLAB\R2019a/extern/lib/win64/mingw64/mexFunction.def"
LINKEXPORTVER : -Wl,"C:\Program Files\MATLAB\R2019a/extern/lib/win64/mingw64/exportsmexfileversion.def"
LIBLOC : C:\Program Files\MATLAB\R2019a\extern\lib\win64\mingw64
LINKLIBS : -L"C:\Program Files\MATLAB\R2019a\extern\lib\win64\mingw64" -llibmx -llibmex -llibmat -lm -llibmwlapack -llibmwblas
LDOPTIMFLAGS : -s
LDDEBUGFLAGS : -g
OBJEXT : .obj
LDEXT : .mexw64
SETENV : set COMPILER=C:\ProgramData\MATLAB\SupportPackages\R2019a\3P.instrset\mingw_w64.instrset\bin\gcc
set CXXCOMPILER=C:\ProgramData\MATLAB\SupportPackages\R2019a\3P.instrset\mingw_w64.instrset\bin\g++
set COMPFLAGS=-c -fexceptions -fno-omit-frame-pointer -DMATLAB_DEFAULT_RELEASE=R2017b -DUSE_MEX_CMD -m64 -DMATLAB_MEX_FILE -DMATLAB_MEX_FILE
set CXXCOMPFLAGS=-c -fexceptions -fno-omit-frame-pointer -std=c++11 -DMATLAB_DEFAULT_RELEASE=R2017b -DUSE_MEX_CMD -m64 -DMATLAB_MEX_FILE -DMATLAB_MEX_FILE
set OPTIMFLAGS=-O2 -fwrapv -DNDEBUG
set DEBUGFLAGS=-g
set LINKER=C:\ProgramData\MATLAB\SupportPackages\R2019a\3P.instrset\mingw_w64.instrset\bin\gcc
set CXXLINKER=C:\ProgramData\MATLAB\SupportPackages\R2019a\3P.instrset\mingw_w64.instrset\bin\g++
set LINKFLAGS=-m64 -Wl,--no-undefined -shared -static -L"C:\Program Files\MATLAB\R2019a\extern\lib\win64\mingw64" -llibmx -llibmex -llibmat -lm -llibmwlapack -llibmwblas -Wl,"C:\Program Files\MATLAB\R2019a/extern/lib/win64/mingw64/mexFunction.def"
set LINKDEBUGFLAGS=-g
set NAME_OUTPUT=-o "%OUTDIR%%MEX_NAME%%MEX_EXT%"
MINGWROOT : C:\ProgramData\MATLAB\SupportPackages\R2019a\3P.instrset\mingw_w64.instrset
MATLABROOT : C:\Program Files\MATLAB\R2019a
ARCH : win64
SRC : "C:\Users\BryanM\Desktop\MEX Test\yprime.c";"C:\Program Files\MATLAB\R2019a\extern\version\c_mexapi_version.c"
OBJ : C:\Users\BryanM\AppData\Local\Temp\mex_84792488536190_15280\yprime.obj;C:\Users\BryanM\AppData\Local\Temp\mex_84792488536190_15280\c_mexapi_version.obj
OBJS : C:\Users\BryanM\AppData\Local\Temp\mex_84792488536190_15280\yprime.obj C:\Users\BryanM\AppData\Local\Temp\mex_84792488536190_15280\c_mexapi_version.obj
SRCROOT : C:\Users\BryanM\Desktop\MEX Test\yprime
DEF : C:\Users\BryanM\AppData\Local\Temp\mex_84792488536190_15280\yprime.def
EXP : "yprime.exp"
LIB : "yprime.lib"
EXE : yprime.mexw64
ILK : "yprime.ilk"
MANIFEST : "yprime.mexw64.manifest"
TEMPNAME : yprime
EXEDIR :
EXENAME : yprime
OPTIM : -O2 -fwrapv -DNDEBUG
LINKOPTIM : -s
CMDLINE1_0 : C:\ProgramData\MATLAB\SupportPackages\R2019a\3P.instrset\mingw_w64.instrset\bin\gcc -c -DMATLAB_DEFAULT_RELEASE=R2017b -DUSE_MEX_CMD -m64 -DMATLAB_MEX_FILE -I"C:\Program Files\MATLAB\R2019a/extern/include" -I"C:\Program Files\MATLAB\R2019a/simulink/include" -I"C:\Program Files\MATLAB\R2019a/extern\lib\win64\mingw64" -fexceptions -fno-omit-frame-pointer -O2 -fwrapv -DNDEBUG "C:\Users\BryanM\Desktop\MEX Test\yprime.c" -o C:\Users\BryanM\AppData\Local\Temp\mex_84792488536190_15280\yprime.obj
CMDLINE1_1 : C:\ProgramData\MATLAB\SupportPackages\R2019a\3P.instrset\mingw_w64.instrset\bin\gcc -c -DMATLAB_DEFAULT_RELEASE=R2017b -DUSE_MEX_CMD -m64 -DMATLAB_MEX_FILE -I"C:\Program Files\MATLAB\R2019a/extern/include" -I"C:\Program Files\MATLAB\R2019a/simulink/include" -I"C:\Program Files\MATLAB\R2019a/extern\lib\win64\mingw64" -fexceptions -fno-omit-frame-pointer -O2 -fwrapv -DNDEBUG "C:\Program Files\MATLAB\R2019a\extern\version\c_mexapi_version.c" -o C:\Users\BryanM\AppData\Local\Temp\mex_84792488536190_15280\c_mexapi_version.obj
-------------------------------------------------------------------
Building with 'MinGW64 Compiler (C)'.
C:\ProgramData\MATLAB\SupportPackages\R2019a\3P.instrset\mingw_w64.instrset\bin\gcc -c -DMATLAB_DEFAULT_RELEASE=R2017b -DUSE_MEX_CMD -m64 -DMATLAB_MEX_FILE -I"C:\Program Files\MATLAB\R2019a/extern/include" -I"C:\Program Files\MATLAB\R2019a/simulink/include" -I"C:\Program Files\MATLAB\R2019a/extern\lib\win64\mingw64" -fexceptions -fno-omit-frame-pointer -O2 -fwrapv -DNDEBUG "C:\Users\BryanM\Desktop\MEX Test\yprime.c" -o C:\Users\BryanM\AppData\Local\Temp\mex_84792488536190_15280\yprime.obj
C:\ProgramData\MATLAB\SupportPackages\R2019a\3P.instrset\mingw_w64.instrset\bin\gcc -c -DMATLAB_DEFAULT_RELEASE=R2017b -DUSE_MEX_CMD -m64 -DMATLAB_MEX_FILE -I"C:\Program Files\MATLAB\R2019a/extern/include" -I"C:\Program Files\MATLAB\R2019a/simulink/include" -I"C:\Program Files\MATLAB\R2019a/extern\lib\win64\mingw64" -fexceptions -fno-omit-frame-pointer -O2 -fwrapv -DNDEBUG "C:\Program Files\MATLAB\R2019a\extern\version\c_mexapi_version.c" -o C:\Users\BryanM\AppData\Local\Temp\mex_84792488536190_15280\c_mexapi_version.obj
C:\ProgramData\MATLAB\SupportPackages\R2019a\3P.instrset\mingw_w64.instrset\bin\gcc -m64 -Wl,--no-undefined -shared -static -s -Wl,"C:\Program Files\MATLAB\R2019a/extern/lib/win64/mingw64/exportsmexfileversion.def" C:\Users\BryanM\AppData\Local\Temp\mex_84792488536190_15280\yprime.obj C:\Users\BryanM\AppData\Local\Temp\mex_84792488536190_15280\c_mexapi_version.obj -L"C:\Program Files\MATLAB\R2019a\extern\lib\win64\mingw64" -llibmx -llibmex -llibmat -lm -llibmwlapack -llibmwblas -o yprime.mexw64
Error using mex
The command 'C:\ProgramData\MATLAB\SupportPackages\R2019a\3P.instrset\mingw_w64.instrset\bin\gcc' exited with a return value '0'

Sign in to comment.

Answers (1)

Marko Järvenpää
Marko Järvenpää on 31 Jul 2019
Edited: Marko Järvenpää on 31 Jul 2019
I had a similar problem using also MATLAB 2019a on a Windows 10 machine. I was able to circumvent the problem using manual installation of MinGW using the instructions in http://khailaie.com/notes/MEX/MEX-MinGW-setup-Windows.html
The instructions are actually given for 2017b but they worked with obvious changes for my 2019a.

  0 Comments

Sign in to comment.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by