Using Visual Studio as C++ compiler for MEX files
71 views (last 30 days)
Show older comments
I'm trying to use the following tool with MATLAB 2019a on Windows 10: https://github.com/MouseLand/Kilosort2
The installation instructions say to use Visual Studio 2013 to compile mex files and I've installed the parallel computing and signal processing toolboxes along with CUDA 10.0.
I've tried using
mex -setup
and
mex -setup c++
to set VS 2013 as the compiler, but MATLAB can't seem to find it and returns the following error
% Error using mex
% No supported compiler was found. You can install the freely available MinGW-w64 C/C++ compiler; see Install
% MinGW-w64 Compiler. For more options, visit https://www.mathworks.com/support/compilers.
Now I have found documentation here https://www.mathworks.com/support/requirements/previous-releases.html that indicates that VS2013 isn't a supported compiler in MATLAB 2019a - or any other recent version - but I know this tool is very popular within neuroscience and no one on the github page linked above seems to have had any problems establishing VS2013 as the compiler.
Any ideas are welcome and I appreciate the help.
Edit: I am using "Visual Studio Community 2013 with Update 5", but the authors of the github page indicate that this is permissable as they recommend VS because it is free (only the Community version is free)
0 Comments
Answers (3)
asaf benjamin
on 15 Jan 2020
I had the exact same problem using MATLAB 2019b on Windows 10. Notice that running
mex -setup -v
shows that Matlab isn't looking for VS 2013, only 2015 and later. I downloaded and installed MSVS 2015 Community for free, used a custom instalation with all the C++ components included, and then ran
mex -setup
and set the C and C++ compiler to VS 2015. After that it worked like a charm. Hopes this help others...
2 Comments
Stefan Oline
on 10 Aug 2020
I just want to thank you for documenting this solution. I've been running in circles following the KiloSort2 installation instructions. Using 2013 and 2019 both failed but 2015 did work for me (even though MATLAB complained while executing mexGPUall.m). +1
Subhadeep Koley
on 2 Aug 2019
MinGW is one of the supported compilers in MATLAB R2019a for mex file compilation according to the documentation.
0 Comments
Torben Ott
on 4 Dec 2020
Thanks for bringing this up! Same issue for me with MATLAB R2019b trying to install kilosort2. Installing VS2015 Community instead of VS2013 recommended in the readme solved it (choose VS2015 as your compiler in MATLAB with mex -setup). When installing VS2015 select Programming Languages -> C++.
0 Comments
See Also
Categories
Find more on Electrophysiology in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!