Matlab mex lstdc++ not found

I'm trying to compile a mex file in matlab. I'm running Ubuntu 14.04 and Matlab R2014b. The first dependency issue I faced was the GCC which needed a version 4.7.x, while my system was running 4.8.x. I fixed that by changing mexopts.sh and putting that in my Matlab/R2014 path. Now, I get this error:

mex ic.c -largeArrayDims -v
-> mexopts.sh sourced from directory (DIR = $PREF_DIR) **FILE = /home/kyouma/.matlab/R2014b/mexopts.sh
----------------------------------------------------------------**
-> MATLAB = /usr/local/MATLAB/R2014b
-> CC = gcc-4.7
-> CC flags: CFLAGS = -ansi -D_GNU_SOURCE -fexceptions -fPIC -fno-omit-frame-pointer -pthread CDEBUGFLAGS = -g COPTIMFLAGS = -O -DNDEBUG CLIBS = -Wl,-rpath-link,/usr/local/MATLAB/R2014b/bin/glnxa64 -L/usr/local/MATLAB/R2014b/bin/glnxa64 -lmx -lmex -lmat -lm -lstdc++ arguments =
-> CXX = g++-4.7
-> CXX flags: CXXFLAGS = -ansi -D_GNU_SOURCE -fPIC -fno-omit-frame-pointer -pthread CXXDEBUGFLAGS = -g CXXOPTIMFLAGS = -O -DNDEBUG CXXLIBS = -Wl,-rpath-link,/usr/local/MATLAB/R2014b/bin/glnxa64 -L/usr/local/MATLAB/R2014b/bin/glnxa64 -lmx -lmex -lmat -lm arguments =
-> FC = gfortran
-> FC flags: FFLAGS = -fexceptions -fbackslash -fPIC -fno-omit-frame-pointer FDEBUGFLAGS = -g FOPTIMFLAGS = -O FLIBS = -Wl,-rpath-link,/usr/local/MATLAB/R2014b/bin/glnxa64 -L/usr/local/MATLAB/R2014b/bin/glnxa64 -lmx -lmex -lmat -lm arguments =
-> LD = gcc-4.7
-> Link flags: LDFLAGS = -pthread -shared -Wl,--version-script,/usr/local/MATLAB/R2014b/extern/lib/glnxa64/mexFunction.map -Wl,--no-undefined LDDEBUGFLAGS = -g LDOPTIMFLAGS = -O LDEXTENSION = .mexa64 arguments =
-> LDCXX =
-> Link flags: LDCXXFLAGS = LDCXXDEBUGFLAGS = LDCXXOPTIMFLAGS = LDCXXEXTENSION = **arguments =
----------------------------------------------------------------**
-> gcc-4.7 -c -I/usr/local/MATLAB/R2014b/extern/include -I/usr/local/MATLAB/R2014b/simulink/include -DMATLAB_MEX_FILE -ansi -D_GNU_SOURCE -fexceptions -fPIC -fno-omit-frame-pointer -pthread -O -DNDEBUG "ic.c"
-> gcc-4.7 -O -pthread -shared -Wl,--version-script,/usr/local/MATLAB/R2014b/extern/lib/glnxa64/mexFunction.map -Wl,--no-undefined -o "ic.mexa64" ic.o -Wl,-rpath-link,/usr/local/MATLAB/R2014b/bin/glnxa64 -L/usr/local/MATLAB/R2014b/bin/glnxa64 -lmx -lmex -lmat -lm -lstdc++
/usr/bin/ld: cannot find -lstdc++
collect2: error: ld returned 1 exit status mex: link of ' "ic.mexa64"' failed.
Unable to complete successfully.

I tried looking for it, but all the libstdc++ issues I found seem to have something to do with the 6.4 version, and mine doesn't pop any error that seems specific as to the version.

I am new to ubuntu, so any light anyone can throw on this would be greatly appreciated. Thank you.

2

1 Answer

I had to install g++. @steeldriver, thank you for pointing me in the right direction :) I specifically installed a version 4.7 of g++ because my gcc that matlab needed was only 4.7.x,and the mex compilations with my version of matlab were not compatible with the default 4.8 that ubuntu 14.04 runs.

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

You Might Also Like