0

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.

  • Did you actually install g++-4.7? or just gcc-4.7? – steeldriver Jul 6 '15 at 20:14
  • I updated and upgraded ubuntu, and I checked which version of gcc 4.7 was running, it said gcc 4.7.3 was on. I troubleshooted it and I followed what I found here: mathworks.com/matlabcentral/answers/… – stalagmite7 Jul 6 '15 at 20:57
1

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

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.