How to run a C++ code in Matlab
269 views (last 30 days)
KSSV on 22 Feb 2016
You have to write wrappers. You must let MATLAB know that the code is c++; you have to write a code for input and output. The main code in c++ remains the same. You have to use mex compiler. You may read below documentation.
Walter Roberson on 22 Feb 2016
It depends on the form of the C++ code. If it is compatible with being a shared object (such as being a DLL) then you can use loadlibrary() to attach to it, and calllib() to call into it, without needing to change the code. You would need a .h file (or equivalent) to use this.
In most operating systems and compilers, you would need special flags when compiling the C++ source to generate a shared object. In some operating systems, though, you could technically get away with just a normal compile (but you would probably routinely include some special flags for the task anyhow so that you create a better shared object.)