0

I have a problem. I can pass 2D array from Delphi to C++ DLL that created by CodeBlocks. My function in C++ DLL is :

double __declspec(dllexport)  __cdecl mainFunction(double** arr, int64 length)

And my Function In Delphi to call DLL is :

type
 DynMatrixDouble = array of array of double;
.
.
function arr(X:DynMatrixDouble; Y: integer):double; stdcall; external 'Array_dll.dll' name 'mainFunction';

This code works well and the values of the variables are transferred between the program and the dll.But when I convert a function that has a 2D array in input in Matlab to DLL or /to C++ to make DLL with CodeBlocks, It's no longer like the code above, this is :

double calc_det(int64m_T n, const emxArray_real_T *arr)

It seems I should make 2D Double array Variable In "emxArray_real_T" Type in Delphi and pass to DLL. I searched and reached the link below: How to convert float[][] type array to "emxArray_real_T *x" But I couldn't find the answer to my question.My question is how can define "emxArray_real_T" type in Delphi for 2D Array and send it to dll ? Can anyone help me how to do it right? Thanks.

Hamed
  • 13
  • 3
  • In your first method you have translated c++ `int64` to delphi's `integer` type, the latter being a 32-bit signed type and not the same as the 64-bit signed `int64`. It will break if the value of `length` exceeds the maximum value of a signed 32-bit integer. For your question, the c++ header file should have a definition for `int64m_T` and `emxArray_real_T`. A google search finds other matlab headers that define `typedef struct { uint32_T chunks[2]; } int64m_T;`, for example, so this is the structure you need to replicate in Delphi. – J... Oct 18 '19 at 19:25
  • Thank you for response , But I want to know how to convert 2D Double array in Delphi to emxArray_real_T , because I should pass my array data to this DLL. I should make a record in delphi like emxArray_real_T structure , but how to convert my array into this record? – Hamed Oct 18 '19 at 20:06
  • You need to find out what this structure is. Look at the Matlab docs. – David Heffernan Oct 19 '19 at 06:41

0 Answers0