how to solveerror while running c code in matlab

1 view (last 30 days)
I have to run C code.I have installed mingw64 version 5.3 for Matlab 2017b. When I type mex -setup, it says
MEX configured to use 'MinGW64 Compiler (C)' for C language compilation.
Warning: The MATLAB C and Fortran API has changed to support MATLAB
variables with more than 2^32-1 elements. You will be required
to update your code to utilize the new API.
You can find more information about this at:
http://www.mathworks.com/help/matlab/matlab_external/upgrading-mex-files-to-use-64-bit-api.html.
But, when I run the C file it says
Error using mex The command :\Program' exited with a return value '1'
  2 Comments
James Tursa
James Tursa on 6 Mar 2018
You haven't really told us anything other than you have a mex function that doesn't work. How can we possibly help you without any details? E.g., did you write the mex routine yourself or did you get it from somewhere else? Did you compile it yourself? If so, how did you do it and what compiling options did you select? What input arguments are you giving the mex routine? Etc, etc, etc ...
Walter Roberson
Walter Roberson on 6 Mar 2018
Some command was run without quotation marks around a file name. However we do not have enough information at the moment to say what.

Sign in to comment.

Answers (1)

varjak
varjak on 16 Jun 2018
Hi, I had the same error and the problem was the MinGW64 folder was in a directory with a space in it! For example: "C:\Program Files\MinGW\mingw64". That is why Matlab issues the error at ":\Program", right before the space. Place the folder in another directory - I have it in "C:\MinGW\mingw64" and it works.
Note: In the "MinGW Installation Notes" (<http://www.mingw.org/wiki/Getting_Started>) they state: "The preferred installation target directory is C:\MinGW".

Community Treasure Hunt

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

Start Hunting!