CerebusOSS/CereLink

Compiled mex-file uses matlab's QT library instead of the user installed ones

Closed this issue · 2 comments

Hello,

For a long time I couldn't get cbmex to work in matlab on the mac (I was getting a QT version error, even though I installed and compiled with the correct version). I realized that the mex file was by default using matlab's own QT libraries (contained in MATLAB_R2011b/bin/maci64)… and the only solution I found was to actually replace the libraries inside matlab's bundle by more recent ones. But I'm afraid it's not a very good solution and might affect matlab's (relative) stability. Is there a way (either in matlab, or with cmake) to have the mex file load the "normal" libraries (/usr/local/lib) ?

Yes, this is an issue, cbmex requires Qt4.8 if MATLAB's version is older it may not have some of the required functions, and 2011 version may be older than required. I am going to use mmap and avoid Qt's QtShareMemory (which relies on shmem). I think this is the part that needs 4.8, while the rest will work fine with 4.6.
After this change I hope you won't need to replace anything on MATLAB.
MATLAB bundles Qt, but as long it is not used by MATLAB itself it should be Ok, also Qt4.8 is ABI compatible with Qt4.6, so in theory there should not be stability issues, only in theory.
BTW, if you look inside MATLAB's script you see it uses somoe sort of LD_LIBRARY trick to avoid using system libraries in /usr/lib or /usr/local/lib

LD_PRELOAD_LIBRARY can be used, otherwise now we can run in Octave that will be a much smoother experience.