How to run a C++ code in Matlab
134 ビュー (過去 30 日間)
古いコメントを表示
I have a code written in C++. How can I run this code in Matlab? Do I need to write some extra code to be able to run this code in matlab? Or do I need to change it completely? Thanks
0 件のコメント
回答 (3 件)
KSSV
2016 年 2 月 22 日
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.
0 件のコメント
Walter Roberson
2016 年 2 月 22 日
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.)
0 件のコメント
Kestas Subacius
2020 年 1 月 13 日
We've introduced the capability to call C++ libraries directly from MATLAB as of R2019a. Please take a look:
0 件のコメント
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!