我正在尝试从 Train()
-ed DLL调用 #import
函数。
函数在那里,在DLL文件中,我已经确认它是通过DLL-viewer导出的。
我在MQL5中尝试了以下代码来调用DLL函数:
#import "NNModel.dll"
string Train(
double &inpTrain[], // Input training data (1D array carrying 2D data, old first)
double &outTarget[],// Output target data for training (2D data as 1D array, oldest 1st)
double &outTrain[], // Output 1D array to hold net outputs from training
int ntr, // # of training sets
int UEW, // Use Ext. Weights for initialization (1=use extInitWt, 0=use rnd)
double &extInitWt[],// Input 1D array to hold 3D array of external initial weights
double &trainedWt[],// Output 1D array to hold 3D array of trained weights
int numLayers, // # of layers including input, hidden and output
int &lSz[], // # of neurons in layers. lSz[0] is # of net inputs
int AFT, // Type of neuron activation function (0:sigm, 1:tanh, 2:x/(1+x))
int OAF, // 1 enables activation function for output layer; 0 disables
int nep, // Max # of training epochs
double maxMSE // Max MSE; training stops once maxMSE is reached
);
string Test(
double &inpTest[], // Input test data (2D data as 1D array, oldest first)
double &outTest[], // Output 1D array to hold net outputs from training (oldest first)
int ntt, // # of test sets
double &extInitWt[],// Input 1D array to hold 3D array of external initial weights
int numLayers, // # of layers including input, hidden and output
int &lSz[], // # of neurons in layers. lSz[0] is # of net inputs
int AFT, // Type of neuron activation function (0:sigm, 1:tanh, 2:x/(1+x))
int OAF // 1 enables activation function for output layer; 0 disables
);
#import
在C
文件中,我将函数声明为:
MT5_EXPFUNC char* __stdcall Train(
const double* inpTrain, // Input training data (2D data as 1D array, oldest first)
const double* outTarget,// Output target data for training (2D data as 1D array, oldest first)
double* outTrain, // Output 1D array to hold net outputs from training
const int ntr, // # of training sets
const int UEW, // Use External Weights for initialization (1=use extInitWt, 0=use rnd)
const double* extInitWt,// Input 1D array to hold 3D array of external initial weights
double* trainedWt,// Output 1D array to hold 3D array of trained weights
const int numLayers,// # of net layers including input, hidden and output
const int* lSz, // # of neurons in layers. lSz[0] is # of net inputs (nin)
const int AFT, // Type of neuron activation function (0:sigm, 1:tanh, 2:x/(1+x))
const int OAF, // 1 enables activation function for output layer neurons; 0 disables
const int nep, // Max # of training epochs
const double maxMSE // Max MSE; training stops once maxMSE is reached
)
和
MT5_EXPFUNC char* __stdcall Test(
const double* inpTest, // Input test data (2D data as 1D array, oldest first)
double* outTest, // Net outputs from testing
const int ntt, // # of test sets
const double* extInitWt,// Input 1D array to hold 3D array of external initial weights
const int numLayers,// # of net layers including input, hidden and output
const int* lSz, // # of neurons in layers. lSz[0] is # of net inputs (nin)
const int AFT, // Type of neuron activation function (0:sigm, 1:tanh, 2:x/(1+x))
const int OAF // 1 enables activation function for output layer neurons; 0 disables
)
调用指标后,我收到以下错误:
Cannot find 'Train' in 'NNModel.dll'
unresolved import function call
我检查了查看器,DLL中有可用的Train
函数。
这是DLL:NNModel.dll
答案 0 :(得分:0)
string
不是 string
这就是the documentation is clear in this,因为几年前开始的 New -MQL4.56789的早期设计版本,补救措施应从调用接口验证开始。
对于刚刚暂时有效的实际脏 #pragma
-decorated struct{}
- 布局的逆向工程搜索是可能的,但在生产级软件工程中存在永久风险且非常低效...
设计一个简单的界面 - 就像 int aDllCallInterfaceVALIDATOR( <params, ...> );
一样简单,这样任何项目都不适用于MQL4 / 5-side string
-s。
一旦您的调用接口代码集成适用于您的DLL端意图的所有参数,并且还可以将合理的数据/结果返回给MQL4 / 5代码,请返回到预期的功能。
走向简单意味着变得聪明。
(在 string
-s开始在技术上 struct{}
-s时,还有很多头发被撕掉了 - 仍然是New-MQL4.56789重新设计的蠕动岩浆。如果没有必要,不需要重复这种疼痛,是吗?是 :o)
)