Important: Please read the Qt Code of Conduct -

Matlab to c++ in QT

  • I have Matlab code and I want to transform this code using Matlab coder to c++ then use it in QT. Can I do this and how?

  • Lifetime Qt Champion

    Hi and welcome to devnet,

    From a cursory look, use Matlab to generate the library and then use it as any other C++ library.

  • @SGaist said in Matlab to c++ in QT:

    use Matlab to generate the library and then use it as any other C++ library.

    thank you
    Is there any example about that?

  • Lifetime Qt Champion

    About using Matlab's facility to generate C++ ?

  • Thank you sir
    No, I know to use Matlab to generate c++, but after generating c++ from Matlab, how to call this in QT? is there example about that?
    Is this method effective or not?

  • Lifetime Qt Champion

    Qt is a C++ framework, use your library as you would with any other C++ library.

  • I have tried to compile the MATLAB code to a C++ library using the mcc command with the msvc2008 compiler. For my QT C++ code, I'm using mingw to compile. However, when I try to add in the MATLAB converted C++ code there seems to be a lot of problems.


  • Lifetime Qt Champion

    You can't mix and match C++ libraries from different compilers.

    That's is also true for different versions of Visual Studio up to VS2017 that was the first to be backward compatible with VS2015y

  • Banned

    This post is deleted!

  • I'm a grad student who's done most of his programming in Matlab and now, due to speed considerations on numerical simulations, have to program in C++.

    I am familiar with syntax and some level of OOP concepts, but most of my C++ programming so far has been on Linux, where writing (in Vim) and compiling (g++) has never been an issue.


  • different systems have different ABI (application binary interface). It's always safest to compile from sourcecode on the target platform. Assuming the same compiler is used to compile the matlab library as the target system you should be able to link in the .o, .a, or .so library file if you have the correct header to describe the interface functions.

    While matlab is great for non-programmers to do stuff quickly, the matlab c++ output is probably not going to be an optimal c++ object oriented design. Sometimes it is more effective to prove out the algorithm in matlab then hand code it in c++ when porting.

  • Lifetime Qt Champion

    @Chauncey Do you have a question/problem?

  • Hi !

    I would also like to convert matlab code to c ++ but I have a lot of error with MatLab Coder.... Like using the "tiff" function for example..

    I therefore think of redoing everything by hand but I wonder if it is possible to access the matlab functions (like "Tiff") in Qt with a library.

    I think I understood that it was possible to do this but I do not understand how... Is there a general matlab library or should it be created with your project? Is the use of matlab compiler mandatory?

    I'm new to matlab so I'll ask you to be specific please :)

    Thank you in advance :)

  • Banned

    This post is deleted!

  • Banned

    This post is deleted!

Log in to reply