MATLAB: How to use the MATLAB Compiler to convert MATLAB code into a C/C++ source code on Windows and use the GNU compiler in Linux to generate a shared library

clibrarylinuxMATLABMATLAB Compilermccsharedwindows

I would like to do the following steps to generate a shared library that I can use in a Linux machine:
1.Run a MATLAB compile on our Windows system which will generate a C/C++
source file.
2. Take the generated source file and compile it with the GNU compiler on
our Linux system to produce the Linux shared library that we need.

Best Answer

MATLAB compiler does not generate C/C++ source code for the MATLAB code. It only creates a wrapper file for the corresponding MATLAB files, which are platform dependent. The compilation process would use Windows specific compilers and header files to generate these wrapper files. Hence, when attempting to produce a shared library on Linux, the GNU compiler will not be compatible with the C/C++ wrapper files generated on Windows.
To read more about the compilation process, check the following link:
Related Question