Including Matlab into Qt: Runtime Error - Shared object not open



  • I'm trying to include a Matlab program into Qt Creator on Ubuntu by using the Matlab Compiler. Therefore, I use a simple test program. In terminal everything works fine when I export LD_LIBRARY_PATH like this:

    export LD_LIBRARY_PATH=/home/robin/Matlab_Runtime/v93/runtime/glnxa64:/home/robin/Matlab_Runtime/v93/bin/glnxa64:/home/robin/Matlab_Runtime/v93/sys/os/glnxa64:
    

    and then run the program. Building the project in Qt Creator works fine, too, but on runtime I'm getting:

    An Error has occurred while trying to initialize the MATLAB Runtime.  
    The error is: Fatal error loading library /home/robin/Matlab_Runtime/v93/bin/glnxa64/libmat.so Error: /home/robin/Matlab_Runtime/v93/bin/glnxa64/libmat.so: shared object not open
    An Error has occurred while trying to initialize the MATLAB Runtime.  
    The error is: Fatal error loading library /home/robin/Matlab_Runtime/v93/bin/glnxa64/libmwmclbase.so Error: /home/robin/Matlab_Runtime/v93/bin/glnxa64/libmwmclbase.so: shared object not open
    could not initialize the application properly
    

    My LD_LIBRARY_PATH is:

    /home/robin/Qt/5.9.1/gcc_64/lib:/home/robin/projects_opencv/Matlab_compiler_test/../../Matlab_Runtime/v93/runtime/glnxa64/:/home/robin/Matlab_Runtime/v93/runtime/glnxa64:/home/robin/Matlab_Runtime/v93/bin/glnxa64:/home/robin/Matlab_Runtime/v93/sys/os/glnxa64:/home/robin/Matlab_Runtime/v93/sys/opengl/lib/glnxa64:/home/robin/Matlab_Runtime/v93/extern/include
    

    Relevant lines in my .pro file:

    INCLUDEPATH += /home/robin/Matlab_Runtime/v93/extern/include
    LIBS += -L$$PWD/../../Matlab_Runtime/v93/runtime/glnxa64/ -lmwmclmcrrt
    INCLUDEPATH += $$PWD/../../Matlab_Runtime/v93/runtime/glnxa64
    DEPENDPATH += $$PWD/../../Matlab_Runtime/v93/runtime/glnxa64
    LIBS += -L$$PWD/../../Matlab_Runtime/v93/bin/glnxa64/ -lmat -lmwmclbase
    INCLUDEPATH += $$PWD/../../Matlab_Runtime/v93/bin/glnxa64
    DEPENDPATH += $$PWD/../../Matlab_Runtime/v93/bin/glnxa64
    

    I'm grateful for any kind of help on this. Thank you very much!


  • Moderators

    @Rob123 Are you trying to start your app from QtCreator?
    If so then set the LD_LIBRARY_PATH variable in Run settings of your project (in QtCreator on the left side "Projects/Build & Run".



  • @jsulm Thank you for your answer! I did already. My LD_LIBRARY_PATH in build and run in environment is both: /home/robin/Qt/5.9.1/gcc_64/lib:/home/robin/Matlab_Runtime/v93/runtime/glnxa64:/home/robin/Matlab_Runtime/v93/bin/glnxa64:/home/robin/Matlab_Runtime/v93/sys/os/glnxa64:/home/robin/Matlab_Runtime/v93/sys/opengl/lib/glnxa64:/home/robin/Matlab_Runtime/v93/extern/include


  • Lifetime Qt Champion

    Hi,

    Not to nitpick, but you’re missing the LD_ in the environment variable name. Is it a typo here ?



  • @SGaist just a typo ;) thanks anyway


  • Lifetime Qt Champion

    Did you try to run ldd on these libraries to check their dependencies ?


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.