Incompatible gcc version with mex
65 views (last 30 days)
I run Ubuntu 18.04. When I try to compile files with mex, I get the error message saying that mex requires version 6.3.x of gcc, whereas the default gcc version on 18.04 is 7.3.
So far so good, I try to get my hands on an older version of gcc, but all i can find through the supported repositories is gcc version 6.4. The only way I seem to be able to get specifically version 6.3 is by manually compiling and installing gcc, but frankly, I do not want to go down that rabbit hole.
I have seen your answer regarding why you don't always support the latest gcc version, but can you please at least offer support for the latest version of gcc 6 (i.e. 6.4.x)?
Maria Geffen on 26 Sep 2018
I have the same issue with 2018b... sure enough, it also only supports gcc-6.3.x... this is absolutely maddening.
Ladislav Dobrovsky on 29 May 2020
Edited: Ladislav Dobrovsky on 3 Jul 2020
EDIT, debian package: I have made a .deb package wich installs gcc-6.3 and does not destroy the main gcc installation: https://drive.google.com/file/d/1VYb08z7BQH6LQDimcob_jsDHFjjNO8dY/view?usp=sharing
I have compiled GCC 6.3 inside Virtualbox VM in Ubuntu 16 as gcc-6.3; then copied it back to my linux mint 19.3 (ubuntu 18) and did "make install" and also copied a shared object of a library that was in different version.
It works even with nvcc for cuda.
More in my blog: http://blog.nodev.eu/index.php?controller=post&action=view&id_post=5
Robert on 26 Jun 2018
Edited: Robert on 26 Jun 2018
I agree, Mathworks should have updated 2018a , at the very least, to gcc-6.4 at time of its release, which is was a bug fix to gcc-6.3, the only way to get 6.3 now is to a) compile it yourself, or b) use an old archive repository or .deb file. I have not tried the prerelease 2018b, I wonder what gcc version it supports?
Michal on 1 Jul 2018
Frankly speaking I do not understand why TMW choose the "compatible" compiler version on Linux so terribly. On many distributions officially supported by Matlab is very difficult to install "compatible" gcc version.
On the other hand, in most cases the incompatibility mex warning message has no impact on functionality.
Patrick Amy on 2 Oct 2018
I actually built and installed gcc-6.3 from source after much effort, but I get an error that mex can't find gcc-6.3 for C++ compiling, only for C compiling. So when I run:
>> mex -setup C++ Error using mex No supported compiler was found. For options, visit https://www.mathworks.com/support/compilers.
However, when I run
> mex -setup -v Verbose mode is on. ... Looking for compiler 'gcc' ... ... Executing command 'which gcc' ...Yes ('/usr/bin/gcc'). ... Executing command 'gcc -print-file-name=libstdc++.so' ...Yes ('/usr/lib64/libstdc++.so'). Found installed compiler 'gcc'. ... Looking for compiler 'gcc' ... ... Executing command 'which gcc' ...Yes ('/usr/bin/gcc'). ... Executing command 'gcc -print-file-name=libstdc++.so' ...Yes ('/usr/lib64/libstdc++.so'). Found installed compiler 'gcc'. MEX configured to use 'gcc' for C language compilation.
I know my computer is using gcc-6.3 because when I check the version in the terminal I get
gcc (GCC) 6.3.0 Copyright (C) 2016 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
Could Matlab just not know where to look for the compiler? I already add the /bin file with gcc in it to the path and set the environment variables and what not.
Alexander Kristensen on 12 Mar 2019
Edited: Alexander Kristensen on 12 Mar 2019
I have a similar issue.
Compiling mex files works fine with current gcc compiler (gcc 8.2.0 on Ubuntu 18.10, MATLAB 2018b) but throws a warning message.
However if I try and use mexcuda it throws an error of incompatibility.
"Error using mex.
no supported compiler was found. For options. visit https://www.mathworks.com/support/compilers ..."
But installing the gcc 6.3.x is quite tedious, especially for someone with no experience in that area.
I hope for more assistance for Linux users.
Adam Hyler on 23 Sep 2019
Po-Hsuan Huang on 3 Mar 2020
I just wrote Matlab a service request. Hopefully they will respond to this thread. Have anyone tried to contact Matlab ? Did they reply ?
I will update if I hear back from them.
BRSC User on 6 Apr 2020
I also get tons of error when attempt to use locally developed C++/C based source code with matlab with mex / mexFunction. Look forward for any update form Mathworks OR other netizens for success.
ma la on 11 Sep 2020
A work arround which seems to work in some cases is to use octave to compile the mex.
I am realy surprised that is does, and I have no idea of the limitation or the limits of that workarround. Currently, I compile the mex code with the ubuntu (20.04 LTS) version of octace and then run the code from matlab. I would always recommend to first run an example with known results to validate that the code is actually performing as expected.