CerebusOSS/CereLink

Invalid MEX-file error on Ubuntu 18.04 with Matlab R2018b

Closed this issue · 4 comments

Dear CereLink community,

We've got a Cerebus with Central 7.04 and NSP firmware 7.04. On a remote system, I'm trying to compile CereLink cbmex* for Matlab R2018b in Ubuntu 18.04.

*I've downloaded the Jan 23rd dashesy/CereLink master branch zip file for this

From a raw install of Ubuntu 18.04 I have added packages:

sudo apt install cmake
sudo apt install python-dev
sudo apt install qt5-default

From GitHub I downloaded the CereLink zip file and unzipped into a place where I have write permissions. I ran cmake ., make all, and make install as instructed.

We did get these errors:

-- Could NOT find HDF5
-- Could NOT find Octave
-- Configuring done
CMake Warning at CMakeLists.txt:260 (ADD_LIBRARY):
Cannot generate a safe runtime search path for target cbmex because files
in some directories may conflict with libraries in implicit directories:

runtime library [libQt5Xml.so.5] in /usr/lib/x86_64-linux-gnu may be hidden by files in:
  /usr/local/MATLAB/R2018b/bin/glnxa64
runtime library [libQt5Core.so.5] in /usr/lib/x86_64-linux-gnu may be hidden by files in:
  /usr/local/MATLAB/R2018b/bin/glnxa64

Some of these libraries may not be found correctly.

In spite of these error messages, everything runs and we find that /usr/local/CereLink/cbmex.mexa64 has been created. But open Matlab and what do we get?

cbmex ( 'open' )
Invalid MEX-file '/usr/local/CereLink/cbmex.mexa64': /usr/local/CereLink/cbmex.mexa64: symbol _ZTI9QRunnable version Qt_5 not defined in file
libQt5Core.so.5 with link time reference.

I'm afraid that I just don't understand what this means. If there's anything I can do to help test solutions then please let me know.

Best wishes,
jsdpag

Matlab ships its own version of Qt libraries, make sure they are compatible with the system Qt libraries. You may need to change the build to use same Qt as MATLAB (Qt4?).
Also, try cboct and see if that works

You have a few options. First, you can either modify the LD_LIBRARY_PATH from within Matlab to tell it to use system libraries (this didn't work for me). Second, you can build cbsdk using the same version of Qt that Matlab uses (this worked). Third, you can build cbsdk using static Qt5 (didn't try).

One

In Matlab:

  • setenv('LD_LIBRARY_PATH', '/usr/lib/x86_64-linux-gnu/;/usr/local/MATLAB/R2018a/bin/glnxa64/;/usr/local/MATLAB/R2018a/sys/os/glnxa64/')

However, this didn't work for me. Same error. There's probably some variation on this that will work, but it will require a lot of trial and error and may end up breaking other Matlab functions.

Two

For the second option, first determine which version of Qt you need. I have Matlab R2018a and this uses 5.5.1. You can list Matlab's Qt5 libs by doing a ls /usr/local/MATLAB/<version>bin/glnxa64/libQt5*

  1. Download the Qt5 online installer from here
  2. chmod +x qt-unified-linux-x64-online.run
  3. ./qt-unified-linux-x64-online.run
  4. Using the GUI, expand the Qt tree to find your version and click the checkbox next to Desktop gcc 64-bit for that version.
  5. Continue with the install. For me this was 998 MB.
  6. When configuring CereLink, tell it where to find Qt:
    • rm -Rf build && mkdir build && cd build
    • cmake .. -DQt5_DIR=/home/<username>/Qt/5.5/gcc_64/lib/cmake/Qt5
  7. make
  8. sudo make install

Then in Matlab you can

addpath('/usr/local/CereLink')
cbmex('open')

Three

I'm not going to bother with static Qt5. It's a lot of work.

Thanks cboulay, option 2 was the solution. Matlab R2018b also uses Qt 5.5.

Incidentally, dashesy, I just can't find any man page or google reference to cboct. Qu'est ce que c'est?

@jsdpag cboct is like cbmex but for Octave. If you install liboctave-dev cmake will automatically also compile cboct