C++

C++-MEX files compilation problems under Ubuntu 8.04 (Hardy)

23 September, 2009 - 18:09

How unpleasant I may find it, sometimes I have to use some tools in Matlab at work. Today I stumbled on a problem with compiling MEX-files written in C++ on my Ubuntu 8.04 (Hardy Heron) box. To illustrate, I'll use the example C++ MEX file mexcpp.cpp provided with Matlab (Matlab r2007a) in the extern/examples/mex/ folder.

Out-of-the-box compilation with

mex mexcpp.cpp

gave the following warning:
Warning: You are using gcc version "4.2.4". The earliest gcc version supported with mex is "4.0.0". The latest version tested for use with mex is "4.2.0". To download a different version of gcc, visit http://gcc.gnu.org

Despite the warning a MEX-file mexcpp.mexglx was generated. However, its usage resulted in the following:
Invalid MEX-file '/foo/bar/mexcpp.mexglx': /matlabdir/sys/os/glnx86/libstdc++.so.6: version `GLIBCXX_3.4.9' not found (required by /foo/bar/mexcpp.mexglx).
As a sidenote: compiling MEX-files written in C also caused the warning message, but using the compiled MEX-files did not fail.

Read more...