Search code examples
c++matlabshared-librariesmexmysql-connector

mysql and matlab mex - libmysqlcppconn not finding glibcxx_3.4.15


I'm running ubuntu 12.04 and matlab R2012a.

Not sure what the problem is exactly, but I can build my mex file just fine. But when it is run I receive this error

Invalid MEX-file '/home/br/Documents/MATLAB/langmod/rss2mysql/mexUrl2dbSrc.mexa64':/usr/local/MATLAB/R2012a/bin/glnxa64/../../sys/os/glnxa64/libstdc++.so.6: version `GLIBCXX_3.4.15' not found (required by /usr/local/lib/libmysqlcppconn.so.5)

which I find particularly strange, becuase if I run the following in the terminal

strings /usr/local/MATLAB/R2012a/bin/glnxa64/../../sys/os/glnxa64/libstdc++.so.6 | grep GLIBC

I see:

GLIBCXX_3.4
GLIBCXX_3.4.1
GLIBCXX_3.4.2
GLIBCXX_3.4.3
GLIBCXX_3.4.4
GLIBCXX_3.4.5
GLIBCXX_3.4.6
GLIBCXX_3.4.7
GLIBCXX_3.4.8
GLIBCXX_3.4.9
GLIBCXX_3.4.10
GLIBCXX_3.4.11
GLIBCXX_3.4.12
GLIBCXX_3.4.13
GLIBCXX_3.4.14
GLIBCXX_3.4.15
GLIBCXX_3.4.16
GLIBCXX_3.4.17
GLIBC_2.2.5
GLIBC_2.3
GLIBC_2.14
GLIBC_2.4
GLIBC_2.3.4
GLIBC_2.3.2
GLIBCXX_DEBUG_MESSAGE_LENGTH

What do i do to fix this? Any help would be appreciated.

thanks, Brian


Solution

  • This can occur because Matlab includes its own copy of the library that differs from the one you used to compile it. You can replace the symbolic link to this library so that it points to the system library against with you compiled the mex file. On my machine this would look something like this:

    sudo ln -sf /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.16 /usr/local/MATLAB/R2012a/bin/glnxa64/libstdc++.so.6
    

    See also: /usr/lib/libstdc++.so.6: version `GLIBCXX_3.4.15' not found