Help solve a problem with importing a function from a dll - page 4

 
Good advice about the Eche file. I will try to use it. Of course, you are right, they should be checked. I just wanted to hear your opinion on whether it's worth paying attention to them or not, i.e. checking them. But judging by the description, I think this is what we talked about, what do you think? I'm not very good at practical C++ yet, I understand in my brain that there is nothing globally difficult in writing these converters, but at the moment it still presents some difficulty to me, and therefore I want to solve it as simply as possible, especially if there is a ready-made function...
 

Trust but verify :-). That's right.

 

I'm trying to figure out how to make an implementation in C++ Builder. As far as I understand, to make an EXE file, you have to make a consecutive call to three functions in the WinMain function:

ConvertData_1 (...);

rmatrixsvd(...);

ConvertData_2 (...);

Right? What should we do when forming a DLL? In the same way? I have some doubts... I'm trying to use a book by Arkhangelsky "Programming in C++ Builder...".

But so far to no avail...

 

It makes no difference whether you work in Exe or Dll.

.

Copied my post from page 2 of this thread:

-----------------------------------------------------------

You should declare a function like this
extern "C" bool __declspec(dllexport) __stdcall RMatrixSVD_DLL_ADAPTER(double * in1, double * in2, double * out)
// here, you will of course pass the number of rows and columns
{
//convert input parameters to ap::real_2d_array
ap::real_2d_array a1 = convertPDoubleToReal2DArray(in1);
ap::real_2d_array a2 = ;
.
//calculate
ap::real_2d_array a3;
rmatrixsvd(a1, a2, a3);
.
//translate result of a3 into out
convertReal2DArrayToPDouble(a3, out);
.
return;
}

-----------------------------------------------------------

.

What does the WinMain function have to do with it? It's sort of the entry point to the program...

I apologise of course, but do you understand what the function is?

.

Be honest, from September 2 to 6, how much time have you already spent on this task?

Wouldn't it be better to ask for a 2 hour consultation from an expert (code preparation + explanation)?

 

Thanks, I get it now... All these functions are framed by an external one, which I will export. Sorry, got a bit confused...

About the specialist, I'd love to... if there were one around somewhere. But, unfortunately, there are none, a pity, of course...

This is Kazakhstan... Although there are probably good specialists in Almaty and Astana, but I can't get to them :-), over 1000 km away.

That's why I have to figure it out on my own. Yes, I have already wasted a lot of time :-). Well, never mind ... Moscow was not built in a day. :-) As they say.

 

I don't quite understand about Visual Studio 2010... Is only the Beta version available now? As far as I understand, there is no release yet?

Does Visual Assist come separately?

What about the penultimate release of Visual Studio 2008?

 

Strictly speaking, you'll have enough from 2005. Or 2003.

Visual Assist is a third-party utility.

 

For the task at hand, of course, these are enough. But I want to keep it in perspective. I think this task won't be the last...

But Visual Studio 2009 does not seem to occur, so I asked you about the latest available versions...

To study... ...so study to the very top... :-)

 

Finally something has been born... :-)

But there are some problems during compilation, if you specify that the function is exportable...

If you specify:

1.) int SVD_DLL(double inA[], double outW[], double outU[], double outVT[], int Row, int Col), compiles without errors

2) extern "C" int __declspec(dllexport) __stdcall SVD_DLL(double inA[], double outW[], double outU[], double outVT[], int Row, int Col), then there are errors:

[ILINK32 Error] Error: Unresolved external 'ap::afree(void *)' referenced from \COMP-BSN/MY DOCUMENTS\!ALGORITMS\SVD\SVD_DLL\2009.09.07\PROJECT\DEBUG_BUILD\U_SVD_DLL.OBJ
[ILINK32 Error] Error: Unresolved external 'ap::minint(int, int)' referenced from \COMP-BSN!ALGORITMS\SVD\SVD_DLL\2009.09.07\PROJECT\DEBUG_BUILD\U_SVD_DLL.OBJ
[ILINK32 Error] Error: Unresolved external 'ap::amalloc(unsigned int, unsigned int)' referenced from \COMP-BSN/MY DOCUMENTS!ALGORITMS\SVD\SVD_DLL\2009.09.07\PROJECT\DEBUG_BUILD\U_SVD_DLL.OBJ
[ILINK32 Error] Error: Unresolved external 'rmatrixsvd(ap::template_2d_array<double, 1>, int, int, int, int, ap::template_1d_array<double, 1>&, ap::template_2d_array<double, 1>&, ap::template_2d_array<double, 1>&)' referenced from \COMP-BSN\ MY DOCUMENTS\!ALGORITMS\SVD\SVD_DLL\2009.09.07\PROJECT\DEBUG_BUILD\U_SVD_DLL.OBJ

How can this be interpreted?

Maybe there is some mistake in my code?

Here is the code:

//---------------------------------------------------------------------------

#include <windows.h>
//include "H_svd_dll.h"
//---------------------------------------------------------------------------

#pragma argsused

int WINAPI DllEntryPoint(HINSTANCE hinst, unsigned long reason, void* lpReserved)
{
return 1;
}

//---------------------------------------------------------------------------
#include "stdafx.h"
#include "svd.h"
//---------------------------------------------------------------------------

int Convert_Double_To_Real_2D_Array(double inArr[], ap::real_2d_array outArr, int iRow, int iCol)
{

for(int line = 0; line < iRow; line++)
for(int column = 0; column < iCol; column++)
outArr(line, column) = inArr[line*iCol + column];


return 1;
}

//---------------------------------------------------------------------------

int Convert_Real_1D_Array_To_Double(ap::real_1d_array inArr, double outArr[], int iRow, int iCol)
{
int minmn = ap::minint(iRow, iCol);
for(int i = 0; i < minmn; i++)
outArr[i] = inArr(i);

return 1;
}

//---------------------------------------------------------------------------

int Convert_Real_2D_Array_To_Double(ap::real_2d_array inArr, double outArr[], int iRow, int iCol)
{
for(int line = 0; line < iRow; line++)
for(int column = 0; column < iCol; column++)
outArr[line*iCol + column] = inArr(line, column);

return 1;
}

//---------------------------------------------------------------------------

extern "C" int __declspec(dllexport) __stdcall SVD_DLL(double inA[], double outW[], double outU[], double outVT[], int Row, int Col)
//int SVD_DLL(double inA[], double outW[], double outU[], double outVT[], int Row, int Col)
{
ap::real_2d_array A;
ap::real_1d_array W;
ap::real_2d_array U;
ap::real_2d_array VT;
int Uneeded = 2;
int VTneeded = 2;
int AdditionalMemory = 2;
// allocate memory for arrays
int minmn = ap::minint(Row, Col);
A.setbounds(0, Row-1, 0, Col-1);
W.setbounds(0, minmn-1);
U.setbounds(0, Row-1, 0, Col-1);
VT.setbounds(0, Row-1, 0, Col-1);

//convert input parameters from double to ap::real_2d_array
Convert_Double_To_Real_2D_Array(inA, A, Row, Col);

// svd-decomposition of the matrix
rmatrixsvd(A, Row, Col, Uneeded, VTneeded, AdditionalMemory, W, U, VT);

// convert the result of W, U, VT into out
Convert_Real_1D_Array_To_Double(W, outW, Row, Col);
Convert_Real_2D_Array_To_Double(U, outU, Row, Col);
Convert_Real_2D_Array_To_Double(VT, outVT, Row, Col);

return 1;
}

 
2) extern "C" int __declspec(dllexport) __stdcall SVD_DLL(double inA[], double outW[], double outU[], double outVT[], int Row, int Col), then errors occur:

[ILINK32 Error] Error: Unresolved external 'ap::afree(void *)' referenced from \\COMP-BSN\МОИ ДОКУМЕНТЫ\!ALGORITMS\SVD\SVD_DLL\2009.09.07\PROJECT\DEBUG_BUILD\U_SVD_DLL.OBJ

Dear, if you upload archive with sources, I'll try to compile and link it.

And also - promise to show me the mq4 indicator itself :-).

Reason: