Compiling a Matlab program for MT4 (stuck on error 127)

 

Hi,

Does anyone have some short notes on the steps required to compile a simple Matlab function and create a dll which is then used in MT4?

I`m getting stuck at error 127.

"cannot call function 'add' from dll 'mylib.dll' (error 127)"

I have done the following:

1) Compile and link file called add.m in matlab (I am using the compiler that comes with Matlab, should I use a different compiler?)

mcc -W lib:mylib -T link:lib add.m libmmfile.mlib

2) I copy the created DLL to the experts/libraries dir of MT4

3) I create a def file for my library in experts/libraries dir of MT4

LIBRARY mylib

EXPORTS add

4) I add the following line to my EA:

#import "mylib.dll" double add(double x, double y);


Thanks,

Jason