Hi,
My goal is to create a .dll function from Matlab and Visual C++ 6.0 and import it into MT4. Let me explain what I did, and what results I got.
What I've done:
I made two Matlab functions:
1.
Function output = AddTwo(x,y)
output = x + y;
2.
Function output = MultiplyTwo(x,y)
output = x * y;
Next, I compiled them into a dll using mcc and mbuild compiler Visual C++ 6.0 by using command:
mcc -W cpplib:libmatrix -T link:lib AddTwo MultiplyTwo
(sometimes I've seen another library "libmmfile.mlib" here, but I'm not sure)
Which got me several files, including the .cpp, .h, .dll, .exports, etc. files.
I imported the .dll into a test MT4 EA using a .mqh. In the init() section, I call the two .dll functions as a test.
Results:
When calling AddTwo and MultiplyTwo, I get error 127, which probably means that the function names are mangled or something.
So, I open up the .exports file and see that the functions names are "mlxAddTwo" and "mlxMultiplyTwo". I am not sure so I call these functions in the test EA and the result is a critical error crash of MT4:
I have attached all the necessary files. In my opinion, there is probably a mistake in compiling the .cpp file. In the sample dll EA I have seen these "MT4_EXPFUNC" or something like that. Please, I am pretty desperate here and I would sincerely appreciate if someone took a look at the .cpp and .h files and see how to make them work (dll) in MT4 by changing few things.
I have Microsoft Visual C++ 6.0.
My main goal is to successfully call these two Matlab functions via .dll.
Thank you!
EDIT:
Also, I am not completely familiar with compiling with Visual C++ using .def file. If there is anything I need to do involving .def files, please say.
My goal is to create a .dll function from Matlab and Visual C++ 6.0 and import it into MT4. Let me explain what I did, and what results I got.
What I've done:
I made two Matlab functions:
1.
Function output = AddTwo(x,y)
output = x + y;
2.
Function output = MultiplyTwo(x,y)
output = x * y;
Next, I compiled them into a dll using mcc and mbuild compiler Visual C++ 6.0 by using command:
mcc -W cpplib:libmatrix -T link:lib AddTwo MultiplyTwo
(sometimes I've seen another library "libmmfile.mlib" here, but I'm not sure)
Which got me several files, including the .cpp, .h, .dll, .exports, etc. files.
I imported the .dll into a test MT4 EA using a .mqh. In the init() section, I call the two .dll functions as a test.
Results:
When calling AddTwo and MultiplyTwo, I get error 127, which probably means that the function names are mangled or something.
So, I open up the .exports file and see that the functions names are "mlxAddTwo" and "mlxMultiplyTwo". I am not sure so I call these functions in the test EA and the result is a critical error crash of MT4:
QuoteDislikedThere has been a critical error
Time...
I have Microsoft Visual C++ 6.0.
My main goal is to successfully call these two Matlab functions via .dll.
Thank you!
EDIT:
Also, I am not completely familiar with compiling with Visual C++ using .def file. If there is anything I need to do involving .def files, please say.
Attached File(s)
Matlab DLL.zip
87 KB
|
305 downloads