MATLAB Answers


How to get working Matlab Coder in Linux

Asked by Maikol Solís Chacón on 24 May 2011


I followed the Webminar about Generating C++ code with Matlab Coder (<>) 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/ version `GLIBCXX_3.4.14' not found (required by /usr/lib/
    3   /usr/lib/gcc/x86_64-unknown-linux-gnu/4.5.3/cc1: /opt/MATLAB/R2011a/sys/os/glnxa64/ version `GLIBCXX_3.4.11' not found (required by /usr/lib/
    4   /usr/lib/gcc/x86_64-unknown-linux-gnu/4.5.3/cc1: /opt/MATLAB/R2011a/sys/os/glnxa64/ version `GLIBCXX_3.4.14' not found (required by /usr/lib/
    5   /usr/lib/gcc/x86_64-unknown-linux-gnu/4.5.3/cc1: /opt/MATLAB/R2011a/sys/os/glnxa64/ version `GLIBCXX_3.4.11' not found (required by /usr/lib/
    6   /usr/lib/gcc/x86_64-unknown-linux-gnu/4.5.3/cc1: /opt/MATLAB/R2011a/sys/os/glnxa64/ version `GLIBCXX_3.4.11' not found (required by /usr/lib/
    7   gmake: *** [product.o] Error 1

Anyone has a clue what happened?

Thanks in advance,



Log in to comment.

2 Answers

Answer by 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) '', 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.



Log in to comment.

Answer by Maikol Solís Chacón on 24 May 2011


I think i got it. I followed this (<>)

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.


Log in to comment.

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today