How to manually edit MatLab Coder .mex-file code to support 64bit indexing

18 ビュー (過去 30 日間)
Hey,
I have a problem that mex files generated by MatLab Coder only supports 32bit indexing, which is the reason my program gets an error when the input of the bottleneck mex function exceeds an input boolean matrix which has more than 2^31 elements.
I know that mex-files support 64bit indexing when they are hand written, but since I am not comfortable with c or c++, I wonder if there is a way, and if so how, to manually correct this at the end of the coder when it shows me the code it generated?
I read that i shoukld have to replace the 'int32_T' by 'size_t' but thats not all, I would also need to replace the the constructors 'coder::array<T, 1U>' with C MEX API... and thats the point where my knowledge ends and I would need some help about what to do exactly and how to do it.
May be someone coukld help me with that.
Best regards and many thanks in advance

採用された回答

Nitin Kapgate
Nitin Kapgate 2020 年 12 月 18 日
編集済み: Nitin Kapgate 2020 年 12 月 18 日
So you will need to manually change the codein C/C++ files.
You can refer to the guide to enable support for 64-bit indexing in MEX files using compatibleArrayDims flag in mex command.
You can use these additional instructions to upgrade MEX files to use 64-Bit API.
  2 件のコメント
gregory pais
gregory pais 2022 年 6 月 7 日
編集済み: gregory pais 2022 年 6 月 7 日
mex compiler indicates you that functions emlrt are not found. To solve it you have to indicate to the linker where these functions are present. These functions are present in libemlrt.lib under matlabroot\extern\lib\mingw64. You have to add the library file to the mex command like this mex -v *.cpp '-llibemlrt'.
Probably you have to add libmwmathutil where muDouble functions like muDoubleScalarMin are defined.
mex -v *.cpp '-llibemlrt' '-llibmwmathutil'

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

その他の回答 (0 件)

カテゴリ

Find more on Write C Functions Callable from MATLAB (MEX Files) in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by