Clear Filters
Clear Filters

Matlab Engine / Linux problem - Linker Errors...

7 views (last 30 days)
Arwel on 16 Mar 2017
Answered: Dhruvesh Patel on 20 Mar 2017
Hi, I'm trying to compile a simple Matlab engine app, and am hitting some linker problems.
I'm trying to use the Engine in an Eclipse project, and am essentially trying to repeat what was done in this example...
I've configured as described in the above link, and it builds ok, but then hits linker problems, and I get the following error....
Building target: matlabEngine_demo
Invoking: GCC C Linker
gcc -L/usr/local/MATLAB/R2016b/bin/glnxa64 -Xlinker -rpath -Xlinker /usr/local/MATLAB/R2016b/bin/glnxa64 -o "matlabEngine_demo" ./src/matlabEngine_demo.o -leng -lmx
/usr/local/MATLAB/R2016b/bin/glnxa64/ undefined reference to `std::__throw_out_of_range_fmt(char const*, ...)@GLIBCXX_3.4.20'
/usr/local/MATLAB/R2016b/bin/glnxa64/ undefined reference to `__cxa_throw_bad_array_new_length@CXXABI_1.3.8'
collect2: error: ld returned 1 exit status
make: *** [matlabEngine_demo] Error 1
Clearly I have a problem somewhere. Does anyone have any idea what is going on? (This is RHEL7, Matlab R2016b, Eclipse Oxygen CDT)
Cheers, Arwel

Answers (1)

Dhruvesh Patel
Dhruvesh Patel on 20 Mar 2017
As I understand, you are calling MATLAB engine in your C/C++ application and facing linker errors which are thrown while looking for functions which are used by
Looking at the symbols that are missing ('std::__throw_out_of_range_fmt(char const*, ...)' ) it seems that your application is linked to a wrong version of 'libstdc++'. My guess is that you are using gcc version lower than gcc 4.9.
Here I could say that linking your application with (or above) will fix the issue that you have mentioned. But that would not fix all the issue that you might face in the future while calling MATLAB in your C/C++ application.
The and which ship with MATLAB R2016b are configured to be used with a particular version of gcc (gcc 4.9x to be precise). The gcc 4.9 comes with version 6.0.20 of as stated in the documentation.
So, updating your gcc to version 4.9x would be the best way to avoid this as well as all other linker errors that you might get on your current setup with MATLAB R2016b.
I hope this helps.


Find more on MATLAB Compiler in Help Center and File Exchange


Community Treasure Hunt

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

Start Hunting!