compile C code in matlab from linux

I am getting this error when i try to compile the engdemo.c
The command used is.
mex -f engopts.sh engdemo.c -v
/cad/local/apps/mathworks/matlab/2009a/bin/glnxa64/libmx.so: undefined reference to `std::basic_ostream<char, std::char_traits<char> >& std::__ostream_insert<char, std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*, long)@GLIBCXX_3.4.9'
/cad/local/apps/mathworks/matlab/2009a/bin/glnxa64/libmwfl.so: undefined reference to `std::basic_ostream<char, std::char_traits<char> >& std::basic_ostream<char, std::char_traits<char> >::_M_insert<void const*>(void const*)@GLIBCXX_3.4.9'
/cad/local/apps/mathworks/matlab/2009a/bin/glnxa64/libut.so: undefined reference to `std::basic_ostream<char, std::char_traits<char> >& std::basic_ostream<char, std::char_traits<char> >::_M_insert<long>(long)@GLIBCXX_3.4.9'
/cad/local/apps/mathworks/matlab/2009a/bin/glnxa64/libut.so: undefined reference to `std::basic_ostream<char, std::char_traits<char> >& std::basic_ostream<char, std::char_traits<char> >::_M_insert<bool>(bool)@GLIBCXX_3.4.9'
/cad/local/apps/mathworks/matlab/2009a/bin/glnxa64/libmx.so: undefined reference to `std::basic_ostream<char, std::char_traits<char> >& std::basic_ostream<char, std::char_traits<char> >::_M_insert<unsigned long>(unsigned long)@GLIBCXX_3.4.9'
/cad/local/apps/mathworks/matlab/2009a/bin/glnxa64/libmwfl.so: undefined reference to `std::bad_alloc::what() const@GLIBCXX_3.4.9'
/cad/local/apps/mathworks/matlab/2009a/bin/glnxa64/libmx.so: undefined reference to `std::basic_ostream<char, std::char_traits<char> >& std::basic_ostream<char, std::char_traits<char> >::_M_insert<double>(double)@GLIBCXX_3.4.9'
collect2: ld returned 1 exit status

 채택된 답변

Kaustubha Govind
Kaustubha Govind 2011년 11월 23일

1 개 추천

What version of gcc are you using? You need gcc 4.2.3 for R2009a on Linux. Make sure that you select this compiler with "mex -setup". If you are indeed using gcc 4.2.3, you may need to update your libstdc++ libraries to match your gcc version. For gcc 4.2.3, libstdc++.so.6.0.9 or higher is required.

댓글 수: 2

Subin
Subin 2011년 11월 25일
Thanks for the reply. But the matlab(R2009a) was showing the supported gcc version is from 4.1 to 4.2. I am using 4.1.2.
How to check libstdc++ library version?
Kaustubha Govind
Kaustubha Govind 2011년 11월 28일
Try "ls -l /usr/lib/libstdc++*" at the system shell.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Write C Functions Callable from MATLAB (MEX Files)에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by