Monday, November 7, 2011

mysql.m compile 64 bit ubuntu linux

So I downloaded the awesome file exchange mysql.cpp file to link Matlab.

http://www.mathworks.com/matlabcentral/fileexchange/8663-mysql-database-connector

Then I installed the mysql and the extra libraries I thought I needed.

Then in Matlab I ran:

mex -I/usr/include/mysql -L/usr/lib/mysql -lmysqlclient mysql.cpp

and I got this error:

Warning: You are using gcc version "4.5.2-8ubuntu4)". The version
currently supported with MEX is "4.3.4".
For a list of currently supported compilers see:
http://www.mathworks.com/support/compilers/current_release/

/usr/lib/x86_64-linux-gnu/gcc/x86_64-linux-gnu/4.5.2/cc1plus: /home/snow/matlab2011/sys/os/glnxa64/libstdc++.so.6: version `GLIBCXX_3.4.14' not found (required by /usr/lib/libppl_c.so.2)
/usr/lib/x86_64-linux-gnu/gcc/x86_64-linux-gnu/4.5.2/cc1plus: /home/snow/matlab2011/sys/os/glnxa64/libstdc++.so.6: version `GLIBCXX_3.4.11' not found (required by /usr/lib/libppl_c.so.2)
/usr/lib/x86_64-linux-gnu/gcc/x86_64-linux-gnu/4.5.2/cc1plus: /home/snow/matlab2011/sys/os/glnxa64/libstdc++.so.6: version `GLIBCXX_3.4.14' not found (required by /usr/lib/libppl.so.7)
/usr/lib/x86_64-linux-gnu/gcc/x86_64-linux-gnu/4.5.2/cc1plus: /home/snow/matlab2011/sys/os/glnxa64/libstdc++.so.6: version `GLIBCXX_3.4.11' not found (required by /usr/lib/libppl.so.7)
/usr/lib/x86_64-linux-gnu/gcc/x86_64-linux-gnu/4.5.2/cc1plus: /home/snow/matlab2011/sys/os/glnxa64/libstdc++.so.6: version `GLIBCXX_3.4.11' not found (required by /usr/lib/libgmpxx.so.4)

mex: compile of ' "mysql.cpp"' failed.

After digging around on the Internet I finally found the solution, and it was very simple:

Navigate to here:

$MATLAB_ROOT/sys/os/glnxa64/

(first make a backup of that folder just in case). and run these two commands:

mv libstdc++.so.6 libstdc++.so.6.orig
mv libgcc_s.so.1 libgcc_s.so.1.orig

Then I didn't even need to restart my Matlab session, I just reran the mex compile command it it worked! Yay!




1 comment:

gocen said...

I did same things but it did not worked