Skip to content

Instantly share code, notes, and snippets.

@bonanza123
Created September 5, 2016 12:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bonanza123/bb38a9a95e450e2bc99a6ac8d8513cf2 to your computer and use it in GitHub Desktop.
Save bonanza123/bb38a9a95e450e2bc99a6ac8d8513cf2 to your computer and use it in GitHub Desktop.
MATLAB usually requires acient gcc versions to compile MEX files (e.g. v4.9.x for R2016b). However, archlinux usually ships with the most recent version of gcc and this may results in some conflicts with linked C++ ABI.
Fortunately, archlinux AUR provides also older gcc versions (such as gcc49). The problem is that MATLAB's `mex -setup` doesn't find these additionally installed gcc versions. The solution is to go into your local mex config in:
`/home/XX/.matlab/R2016b/mex_C++_glnxa64.xml`
and replace the line
`<cmdReturns name="which g++" />`
e.g. with
`<cmdReturns name="which g++-4.9" />`.
Additionally, change
`<cmdReturns name="g++ -print-file-name=libstdc++.so"`
to
`<cmdReturns name="g++-4.9 -print-file-name=libstdc++.so"`.
Then try to run `mex.getCompilerConfigurations('C++','Selected')` from MATLAB and verify the settings.
(Don't forget to the same if the mex_C xml files etc).
@alec-hoyland
Copy link

I had catastrophic failure with mex for C++. For some reason, the mex_C++_glnxa64.xml file didn't exist. This fixed it!

Thanks!

@ElektrikAkar
Copy link

Dear bonanza123,

Thanks for pointing out the solution, do you also have a solution for 2018b which requires 6.3.x version? I could find all version but 6.3.x. I tried 6.5.0 but that also does not seem to work. :(

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment