How to get working Matlab Coder in Linux

16 views (last 30 days)
Hello,
I followed the Webminar about Generating C++ code with Matlab Coder (<http://www.mathworks.com/company/events/webinars/wbnr56354.html?id=56354&p1=869881600&p2=869881618>) and i tried to replicate the easy examples in Linux.
I started with
function c = foo(a,b) %#codegen
c = a * b;
and I generate the project, but in the build process I got severals errors messages like:
Build error: Compilation returned error status code 2. See the target build log for further details.
1 gcc -c -ansi -D_GNU_SOURCE -fexceptions -fPIC -fno-omit-frame-pointer -pthread -DMX_COMPAT_32 -g -I "/opt/MATLAB/R2011a/extern/include" -I "/opt/MATLAB/R2011a/simulink/include" -I "/opt/MATLAB/R2011a/toolbox/shared/simtargets" -I "/opt/MATLAB/R2011a/rtw/ext_mode/common" -I "/opt/MATLAB/R2011a/rtw/c/src/ext_mode/common" -I "/home/mikesol/Documents/2010/Cpp/MatlabCpp/codegen/mex/product" -I "/home/mikesol/Documents/2010/Cpp/MatlabCpp" "product.c"
2 /usr/lib/gcc/x86_64-unknown-linux-gnu/4.5.3/cc1: /opt/MATLAB/R2011a/sys/os/glnxa64/libstdc++.so.6: version `GLIBCXX_3.4.14' not found (required by /usr/lib/libppl_c.so.4)
3 /usr/lib/gcc/x86_64-unknown-linux-gnu/4.5.3/cc1: /opt/MATLAB/R2011a/sys/os/glnxa64/libstdc++.so.6: version `GLIBCXX_3.4.11' not found (required by /usr/lib/libppl_c.so.4)
4 /usr/lib/gcc/x86_64-unknown-linux-gnu/4.5.3/cc1: /opt/MATLAB/R2011a/sys/os/glnxa64/libstdc++.so.6: version `GLIBCXX_3.4.14' not found (required by /usr/lib/libppl.so.9)
5 /usr/lib/gcc/x86_64-unknown-linux-gnu/4.5.3/cc1: /opt/MATLAB/R2011a/sys/os/glnxa64/libstdc++.so.6: version `GLIBCXX_3.4.11' not found (required by /usr/lib/libppl.so.9)
6 /usr/lib/gcc/x86_64-unknown-linux-gnu/4.5.3/cc1: /opt/MATLAB/R2011a/sys/os/glnxa64/libstdc++.so.6: version `GLIBCXX_3.4.11' not found (required by /usr/lib/libgmpxx.so.4)
7 gmake: *** [product.o] Error 1
Anyone has a clue what happened?
Thanks in advance,
Michael.

Answers (2)

John Elliott
John Elliott on 24 May 2011
Hi, It appears that you have an incomplete install of the gcc compiler. Based on the build log, the 'gcc' command requires (for example) 'libstdc++.so', which apparently isn't installed on your machine.
Have you tried compiling the standard 'hello world' C program on your Linux system? This would be a quick check to see if you have a good install of gcc.
-John

Maikol Solís Chacón
Maikol Solís Chacón on 24 May 2011
Hi,
I think i got it. I followed this (<http://www.mathworks.com/support/solutions/en/data/1-QBCS1/?solution=1-QBCS1>)
cd $MATLAB
cd sys/os/glnx86
mkdir old
mv libstdc++.* libg2c.* libgcc_s* old
After i have to add /usr/lib to the enviroment variables
export LD_LIBRARY_PATH=/usr/lib32:/usr/lib:$LD_LIBRARY_PATH
and it's all, Matlab should be use the libraries from Linux instead of the Matlab ones.
Thanks for your help.

Categories

Find more on C Shared Library Integration in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!