6
$\begingroup$

Per the instructions here I should post a question on this forum with my bug. Essentially I have an error when compiling mengine. I'm trying to run a mathematica notebook on a linux server which needs to call matlab, so I'm in the process of installing MATLink. See log messages at the end of this post for the error. Things I've checked:

  • I've made sure both math and matlab are in PATH.
  • Mathematica can call matlab from within.
  • I have MATLAB 9.5.0.1265761 (R2018b) Update 6, which as seen here (very last page) requires gcc 6.3.x. I have tried both with gcc9 and gcc6 and it doesn't work. Current version is gcc (Ubuntu 6.5.0-2ubuntu1~16.04) 6.5.0 20181026.
  • I've run apt-get install uuid-dev and installed it without problems.
  • I've installed csh without problems.

Thank you for the time.


Linux version:

   Static hostname: ecb22
         Icon name: computer-vm
           Chassis: vm
        Machine ID: 31e79e4e754145a2aea3fec8b9baabef
           Boot ID: 2fc0465ca7764389a2bc7f1938bdf4a4
    Virtualization: kvm
  Operating System: Ubuntu 16.04.6 LTS
            Kernel: Linux 4.4.0-119-generic
      Architecture: x86-64

Developer info:

In[2]:= MATLink`Developer`GetInfo[]
MATLink 1.1 for Unix (Fri 15 Aug 2014)12.1.0 for Linux x86 (64-bit) (March 18, 2020)
>   csh:    g++:        MATLAB:
    /bin/csh/usr/bin/g++/home/ubuntu/MATLAB18/bin
>   libuuid:
        libuuid.so.1 (libc6,x86-64) => /lib/x86_64-linux-gnu/libuuid.so.1
        libuuid.so (libc6,x86-64) => /usr/lib/x86_64-linux-gnu/libuuid.so
>   System PATH:
    /home/ubuntu/bin
    /home/ubuntu/.local/bin
    /home/ubuntu/anaconda3/bin
    /home/ubuntu/anaconda3/condabin
    /usr/local/sbin
    /usr/local/bin
    /usr/sbin
    /usr/bin
    /sbin
    /bin
    /usr/games
    /usr/local/games
    /home/ubuntu/mosek/9.1/tools/platform/linux64x86/bin
    /home/ubuntu/mosek/mosek.lic
    /home/ubuntu/MATLAB18/bin/

Compiling engine from within Mathematica:

In[3]:= MATLink`Developer`CompileMEngine[]
Compiling the MATLink Engine from source...

g++ -O -Wall -I/usr/local/Wolfram/Mathematica/12.1/Executables/../SystemFiles/Links/MathLink/DeveloperKit/Linux-x86-64/CompilerAdditions -I/home/ubuntu/MATLAB18/bin/../extern/include -L/usr/local/Wolfram/Mathematica/12.1/Executables/../SystemFiles/Links/MathLink/DeveloperKit/Linux-x86-64/CompilerAdditions -L/home/ubuntu/MATLAB18/bin/../bin/glnxa64 menginetm.cpp mengine.cpp set.cpp get.cpp main.cpp -Wl,-rpath-link,/home/ubuntu/MATLAB18/bin/../bin/glnxa64/ -DMLINTERFACE=3 -lML64i3 -luuid -lmx -leng -o mengine
set.cpp: In function 'void eng_make_ComplexArray(double*, int, double*, int, int*, int ':
set.cpp:95:43: error: 'mxGetPiIsDeprecated' was not declared in this scope
     std::copy(imag, imag+ilen, mxGetPi(var));
                                           ^
set.cpp: In function 'void eng_make_SparseComplex(int*, int, int*, int, double*, int, double*, int, int, int)':
set.cpp:116:43: error: 'mxGetPiIsDeprecated' was not declared in this scope
     std::copy(imag, imag+ilen, mxGetPi(var));
                                           ^
set.cpp: In function 'void eng_make_String(const short unsigned int*, int)':
set.cpp:160:31: warning: narrowing conversion of 'len' from 'int' to 'mwSize {aka long unsigned int}' inside { } [-Wnarrowing]
     mwSize mbDims[2] = {1, len};
                               ^
In file included from /usr/include/c++/6/cassert:44:0,
                 from set.cpp:13:
set.cpp: In function 'void eng_make_Struct()':
set.cpp:192:39: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     assert(mxGetNumberOfElements(var) == len);

get.cpp: In function 'void toMma(const mxArray*, MLINK)':
get.cpp:95:54: error: 'mxGetPiIsDeprecated' was not declared in this scope
                     MLPutReal64List(link, mxGetPi(var), nnz); break;
                                                      ^
get.cpp:97:70: error: 'mxGetImagDataIsDeprecated' was not declared in this scope
                     MLPutReal32List(link, (float *) mxGetImagData(var), nnz); break;
                                                                      ^
get.cpp:133:55: error: 'mxGetPiIsDeprecated' was not declared in this scope
                     MLPutReal64Array(link, mxGetPi(var), mmDims, NULL, depth); break;
                                                       ^
get.cpp:135:71: error: 'mxGetImagDataIsDeprecated' was not declared in this scope
                     MLPutReal32Array(link, (float *) mxGetImagData(var), mmDims, NULL, depth); break;
                                                                       ^
Makefile.lin64:21: recipe for target 'mengine' failed
make: *** [mengine] Error 1

MATLink`Developer`CompileMEngine::failed:
   Automatically compiling the MATLink Engine has failed. See
    http://matlink.org/troubleshooting/, then try to compile it manually and ensure
    that the path to the MATLAB directory is set correctly in the makefile.

Out[3]= $Aborted

Compiling manually, basically the same error:

(base) $ make -f Makefile.lin64
g++ -O -Wall -I/usr/local/Wolfram/Mathematica/12.1/Executables/../SystemFiles/Links/MathLink/DeveloperKit/Linux-x86-64/CompilerAdditions -I/home/ubuntu/MATLAB18/bin/../extern/include -L/usr/local/Wolfram/Mathematica/12.1/Executables/../SystemFiles/Links/MathLink/DeveloperKit/Linux-x86-64/CompilerAdditions -L/home/ubuntu/MATLAB18/bin/../bin/glnxa64 menginetm.cpp mengine.cpp set.cpp get.cpp main.cpp -Wl,-rpath-link,/home/ubuntu/MATLAB18/bin/../bin/glnxa64/ -DMLINTERFACE=3 -lML64i3 -luuid -lmx -leng -o mengine
set.cpp: In function 'void eng_make_ComplexArray(double*, int, double*, int, int*, int ':
set.cpp:95:43: error: 'mxGetPiIsDeprecated' was not declared in this scope
     std::copy(imag, imag+ilen, mxGetPi(var));
                                           ^
set.cpp: In function 'void eng_make_SparseComplex(int*, int, int*, int, double*, int, double*, int, int, int)':
set.cpp:116:43: error: 'mxGetPiIsDeprecated' was not declared in this scope
     std::copy(imag, imag+ilen, mxGetPi(var));
                                           ^
set.cpp: In function 'void eng_make_String(const short unsigned int*, int)':
set.cpp:160:31: warning: narrowing conversion of 'len' from 'int' to 'mwSize {aka long unsigned int}' inside { } [-Wnarrowing]
     mwSize mbDims[2] = {1, len};
                               ^
In file included from /usr/include/c++/6/cassert:44:0,
                 from set.cpp:13:
set.cpp: In function 'void eng_make_Struct()':
set.cpp:192:39: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     assert(mxGetNumberOfElements(var) == len);

get.cpp: In function 'void toMma(const mxArray*, MLINK)':
get.cpp:95:54: error: 'mxGetPiIsDeprecated' was not declared in this scope
                     MLPutReal64List(link, mxGetPi(var), nnz); break;
                                                      ^
get.cpp:97:70: error: 'mxGetImagDataIsDeprecated' was not declared in this scope
                     MLPutReal32List(link, (float *) mxGetImagData(var), nnz); break;
                                                                      ^
get.cpp:133:55: error: 'mxGetPiIsDeprecated' was not declared in this scope
                     MLPutReal64Array(link, mxGetPi(var), mmDims, NULL, depth); break;
                                                       ^
get.cpp:135:71: error: 'mxGetImagDataIsDeprecated' was not declared in this scope
                     MLPutReal32Array(link, (float *) mxGetImagData(var), mmDims, NULL, depth); break;
                                                                       ^
Makefile.lin64:21: recipe for target 'mengine' failed
make: *** [mengine] Error 1

$\endgroup$

1 Answer 1

7
$\begingroup$

This is an incompatibility between MATLink on Linux and recent versions of MATLAB.

Please open Makefile.lin64 and change the CFLAGS line to read

CFLAGS = -Wall -DMX_COMPAT_32

This will fix it until a new MATLink version becomes available.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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