How can export a mex function from sources into a regular c++ function (shared library)) ?

6 ビュー (過去 30 日間)
mathieu
mathieu 2019 年 1 月 19 日
コメント済み: Mark McBroom 2019 年 1 月 21 日
How do I export mex functions (having the sources) into c++11 code (ie., without mex/matlab dependency) ?
Can I do that with the Library Compiler App [1] to create a shared c++ library (as source) ?
If not, how to adapt the mex functions into a regular c++11 ?

回答 (1 件)

Mark McBroom
Mark McBroom 2019 年 1 月 19 日
To clarify, you have mex functions and you want those translated to a C++ library? Assuming the source code is either C or C++, then you simply need to compile/link into a DLL. You can use any compiler/linker to do this ( vis studio, gcc, etc). If the C/C++ code relies on MATLAB libraries, you can use the mbuild command.
  2 件のコメント
mathieu
mathieu 2019 年 1 月 19 日
編集済み: mathieu 2019 年 1 月 19 日
I actually want to export MEX sources into regular c++ sources, not the binaries in that case.
The same way we can export m functions into c/c++ sources (without matlab dependency).
The MEX sources (a custom matlab function written in c/c++) are relying on many MEX functions (eg., mxIsStruct, mexErrMsgTxt , mxGetField, mxGetPr, mxGetDimensions, mxGetClassID ...). If I transform code into another that does not depend on those mex functions, it would be what I call regular c++ code.
Mark McBroom
Mark McBroom 2019 年 1 月 21 日
There is no way to generate C code for the MEX functions being used in your MEX sources... but the primary purpose of the MEX functions ( mxIsStruct, etc. ) is to all MATLAB to call your your C++ code. If you are planning to use your C++ code outside of MATLAB, then you no longer need these MEX functions. It sounds to me like you will have to modify your C++ code to get rid of all of the usages of MEX functions.

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeC++ Shared Library Integration についてさらに検索

製品


リリース

R2018b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by