[Development] Using mexFunctions with QT in Matlab 2014

Olivier Goffart olivier at woboq.com
Wed Jul 2 18:24:19 CEST 2014


On Wednesday 02 July 2014 18:00:29 Hauke Krüger wrote:
> Hi everyone,
> 
> I have created a mexFunction that allows to open QT dialogs etc in
> Matlab. What it does is to
> create a QT thread - which is not the main thread - and to allocate all
> dialogs within this thread.
> 
> This principle works very well in Windows /Visual Studio but it does no
> longer work in Linux :
> Matlab 2014 comes along with the QT 4.8.xx libraries. If I load the
> mexFunction by calling the
> entry function, Matlab crashes. From the callstack I see that in the
> program flow, functions are addressed
> which are located in shared library libQt5Gui.so but as soon as some QT
> core functionalities are requested,
> a function is called which is located in libQtCore.so deployed in the
> context of QT4!
> 
> It sems that in Microsoft Windows, each DLL is treated in a separate
> logical space making it impossible
> to call a function in the wrong library. In Linux, however, it seems
> that even when using shared libraries,
> all symbols are thrown into one pool of symbols and it is never sure
> which symbol is taken in a call.
> And there seem to be duplicate symbols in QT4 and QT5.
> 
> Is there a chance to influence this behavior in Linux to achieve a
> behavior as that in Microsoft Windows?
> Does anyone have another idea for a work around?
> 
> Ah, by the way, I tested also the LD_PRELOAD option to force use of
> Qt5Core library. In that case, Matlab
> crashes right after boot showing that it is the other way around: Matlab
> calls a QT4 function which finally
> ends up in libQt5Core.so.

You may solve this problem by compiling Qt within a different namespace.
(-qtnamespace option in Qt's configure)

-- 
Olivier 

Woboq - Qt services and support - http://woboq.com - http://code.woboq.org



More information about the Development mailing list