Error 127 calling a dll function ? Please help.

 
Hello all (but most importantly Slawa :)

I am trying to use a dll in an EA, but i get the following error when i try to access its first function:

12:51:17 DllTest DAX,H1: loaded successfully
12:52:01 DllTest DAX,H1: cannot call function 'isInitialized' from dll 'test28. dll' (error 127)
12:52:01 DllTest DAX,H1: expert stopped

unfortunately i couldnt find any description of this error 127. Can You help?

Thanks in advance..
 

Use search, please. https://forum.mql4.com/search/error%20127

You need to include def-file to your dll-project

 
OOps, my bad. thank You!
 
I have created a .def file and put it into experts\libraries, but the problem persists. what am i doing wrong? should I put it somewhere else? or is the format wrong?

LIBRARY dlltest.dll
EXPORTS
bumpStepSizes
createNetwork

is what I am using, should I use decorated names? such as createNetwork@2 etc etc?

Thanks.
 
ok i figured it out, me very stupid :)
 
Exported functions for MT4 created in Visual must be declared as _stdcall, not as _cdecl, which is the standard-declaration of functions in Visual !
 

I'm having the same problem using VB. I've copied my DLL file over. Do I need anything else?


-Jerry

 

Hi Jerry,

If you have created your dll, and not added a DEF file for the function Exports, the names of the functions will be Mangled ... like DoMail() may look like _DoMail@12.

Either add a def file, naming your exports, the file is really simple and looks like the stuff below.

LIBRARY "mqlmail"

EXPORTS

DoMail

TDoSomething

Now you can use the unmangled function names.

If you want to use the mangled names and not add a DEF file you can use the Visual Studio Command Prompt Window with 'dumpbin /exports "MQLMail.dll"' to find the mangled names you have to use in your indicator / expert.

Let me know if this helps,

Thanks

T

 
abiank:
I have created a .def file and put it into experts\libraries,

The .def file is for the linker when building the dll, not for metatrader.


Alternatively you could abandon the use of this ancient C++ entirely and use appropriate and modern language and tools for creating dlls like for example Delphi or FPC/Lazarus. This would save you a lot of headache since everything will be much more intuitive and less error prone.

 
https://forum.mql4.com/17569
 

Is it possible to call the MQL function from the DLL ? like calling AccountNumber() inside the DLL

so I have a plan to call and check the AccountNumber() from the DLL file and not from the MQL (ex4 file)

can someone guide me on how to do that ?

thanks

Reason: