R Hariprasad Rao
R Hariprasad Rao

Reputation: 41

MATLAB MEX C++ file Compiling error g++ command not found

I'm trying to compile a C++ file (mysql.cpp) in MATLAB with MEX Function on Linux server. I'm getting this error which I'm not able to figure out why?

/opt/MATLAB/R2013a/bin/mex: line 1343: g++: command not found
mex: compile of ' "mysql.cpp"' failed.

I use this command:

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

and here are the MEX Compiler Configuration Details: -

-> mexopts.sh sourced from directory (DIR = $PREF_DIR)

   FILE = /root/.matlab/R2013a/mexopts.sh

----------------------------------------------------------------
-> MATLAB             = /opt/MATLAB/R2013a

-> CC                 = gcc

-> CC flags:

  CFLAGS             = -ansi -D_GNU_SOURCE  -fexceptions -fPIC -fno-omit-frame-pointer -pthread

   CDEBUGFLAGS        = -g

   COPTIMFLAGS        = -O -DNDEBUG

   CLIBS              = -Wl,-rpath-link,/opt/MATLAB/R2013a/bin/glnxa64 -L/opt/MATLAB/R2013a/bin/glnxa64 -lmx -lmex -lmat -lm -lstdc++

   arguments          =  -DMX_COMPAT_32

-> CXX                = g++

-> CXX flags:

   CXXFLAGS           = -ansi -D_GNU_SOURCE -fPIC -fno-omit-frame-pointer -pthread

   CXXDEBUGFLAGS      = -g

   CXXOPTIMFLAGS      = -O -DNDEBUG

   CXXLIBS            = -Wl,-rpath-link,/opt/MATLAB/R2013a/bin/glnxa64 -L/opt/MATLAB/R2013a
/bin/glnxa64 -lmx -lmex -lmat -lm

   arguments          =  -DMX_COMPAT_32

-> FC                 = gfortran

-> FC flags:

   FFLAGS             = -fexceptions -fbackslash -fPIC -fno-omit-frame-pointer

   FDEBUGFLAGS        = -g

   FOPTIMFLAGS        = -O

   FLIBS              = -Wl,-rpath-link,/opt/MATLAB/R2013a/bin/glnxa64 -L/opt/MATLAB/R2013a
/bin/glnxa64 -lmx -lmex -lmat -lm

   arguments          =  -DMX_COMPAT_32

-> LD                 = g++

-> Link flags:

   LDFLAGS            = -pthread -shared -Wl,--version-script,/opt/MATLAB/R2013a/extern
/lib/glnxa64/mexFunction.map -Wl,--no-undefined

   LDDEBUGFLAGS       = -g

   LDOPTIMFLAGS       = -O

   LDEXTENSION        = .mexa64

   arguments          =  -Lusr/lib/mysql -lmysqlclient

-> LDCXX                 =


-> Link flags:

   LDCXXFLAGS         =

   LDCXXDEBUGFLAGS    =

   LDCXXOPTIMFLAGS    =

   LDCXXEXTENSION     =

   arguments          =  -Lusr/lib/mysql -lmysqlclient 

Please help me to find out what is wrong.

Upvotes: 0

Views: 3215

Answers (1)

Klemens Morgenstern
Klemens Morgenstern

Reputation: 832

Yeah, you should install a compiler before compiling. Mex is just a tool which calls one underneath and since g++ is the C++ compiler of gcc you should install this one.

As far as I know it will still not work, because matlab supports only gcc 4.3 (not sure about that). So install a gcc and run mex -setup

Afterwards you should be able to compile.

Upvotes: 1

Related Questions