title: compile c++ program eclipse that uses matlab engine
body: <p>I am trying to configure eclipse to compile and run the example <code>engdemo.cpp</code>, that uses the matlab engine. </p>
  
  <p>I followed the instructions written <a href="http://mindchasers.net/knowledge/matlabengine.html" rel="nofollow">here</a>, but I have still errors:</p>
  
  <pre><code>make all 
  Building target: matlabEngine
  Invoking: GCC C++ Linker
  g++ -L/usr/local/MATLAB/R2011a/bin/glnx86 -Xlinker -rpath-link -Xlinker /usr/local/MATLAB/R2011a/bin/glnx86 -o"matlabEngine"  ./engdemo.o   -leng -lm -lmat -lmex -lut
  /usr/bin/ld: ./engdemo.o: undefined reference to symbol 'mxDestroyArray'
  /usr/bin/ld: note: 'mxDestroyArray' is defined in DSO /usr/local/MATLAB/R2011a/bin/glnx86/libmx.so so try adding it to the linker command line
  /usr/local/MATLAB/R2011a/bin/glnx86/libmx.so: could not read symbols: Invalid operation
  collect2: ld returned 1 exit status
  make: *** [matlabEngine] Errore 1
  </code></pre>
  
  <p>When I compile the program from the shell I use these commands, and I have no errors so I can run it.</p>
  
  <pre><code>g++ -c  -I/usr/local/MATLAB/R2011a/extern/include -I/usr/local/MATLAB/R2011a/simulink/include -DMATLAB_MEX_FILE -ansi -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -I/usr/local/MATLAB/R2011a/extern/include/cpp -I/usr/local/MATLAB/R2011a/extern/include -DGLNX86 -DGCC  -DMX_COMPAT_32 -O -DNDEBUG  "engdemo.cpp"
  g++ -O  -o  "engdemo"  engdemo.o  -Wl,-rpath-link,/usr/local/MATLAB/R2011a/bin/glnx86 -L/usr/local/MATLAB/R2011a/bin/glnx86 -leng -lmx -lm
  </code></pre>
  
  <p>But I need to compile in eclipse. 
  Any help?</p>