OpenTrading/OTMql4Zmq

Cannot compile EA: "#import was not closed"

Opened this issue · 10 comments

hailg commented

I installed from source (latest version). After copying all the files I saw that the libraries mq4 are compiled to ex4 successfully. However, when I try to compile the EA, I'll got these errors:

'OTMql4/OTLibLog.ex4' - #import was not closed OTLibLog.mqh 9 9
'OTMql4/OTLibStrings.ex4' - #import was not closed OTLibStrings.mqh 13 9
'OTMql4/OTLibSimpleFormatCmd.ex4' - #import was not closed OTLibSimpleFormatCmd.mqh 9 9
'OTMql4/OTLibJsonFormat.ex4' - #import was not closed OTLibJsonFormat.mqh 6 9
'OTMql4/OTZmqProcessCmd.ex4' - #import was not closed OTZmqProcessCmd.mqh 6 9
'OTMql4/ZmqSendReceive.ex4' - #import was not closed ZmqSendReceive.mqh 12 9

Anyone has the same issue like me?

Those appear because you dont have those files on the libraries folder.

hailg commented

I've checked my MT4 data folder. Inside Libraries/OTMql4 I have all that listed files (both .mq4 and .ex4). Just one thing that may cause this, I've setup my MT4 to use the data folder inside itself, not the one in Users folder. Is this a problem?

try to use the mql4zmq.mq4 here: https://github.com/AustenConrad/mql4zmq/tree/master/examples
it doesnt need all those libraries. But it gives me .dll errors on libzmq.dll. Give feedback if you can make it work with this example.

hailg: we've never seen that error before but the code has not bee compiled recently;
it may be because of a change in Mt4. What build are you using and what platform?

mglcampos: forget that AustenConrad code, and read in our Wiki how this code
was derived from that code, but that code is years out of date.

I'll try to get some time over the next couple of weeks to try recompiling with a recent Mt4.

hailg commented

Hi, I'm using MT4 build 1010 (18/8/2016). I tried on both Mac (with PlayforMac) and Windows machines. Both give me the same errors as above.

hailg commented

Also, can you tell me the Mt4 version that you can build successfully? I will make a try.
Thanks. :)

Opentrading: I understood how your code fixed the AnsiToUnicode problem of Mql4 language update. But now all the messages i send with zeromq to my subscriber are going empty, I dont know why. I only receive a timestamp of the empty message.

I also fixed the empty message problem, i just had to upgrade to the last zeromq version

@hailg I solved the import issue by closing the import statement with another #import.
So for example this is a closed import statement and it works for me:

#import "OTMql4/OTLibMt4ProcessCmd.ex4"
#import

I'm also on Build 1010 and ran into this same problem. Appending #import to the affected files (OTLibLog.ex4, OTLibStrings.ex4, OTZmqProcessCmd.ex4, OTLibSimpleFormatCmd.ex4, OTLibJsonFormat.ex4, OTLibPy27.ex4, OTPyChart.ex4) got me past the import issue, but as-is I now have 53 "function must have a body" errors.

I suspect it might be related to needing to explicitly specify each function you intend to import from an ex4 header, per: https://docs.mql4.com/basis/preprosessor/import

Edit: The function-must-have-a-body errors were caused by me putting #import directly after #import "filename". Eg:

#import "OTMql4/OTZmqProcessCmd.ex4"
#import
string zOTZmqProcessCmd (string uMess);

Instead of:

#import "OTMql4/OTZmqProcessCmd.ex4"
string zOTZmqProcessCmd (string uMess);
#import

After moving the closing #import to the bottom of the following files, I was able to build and run OTPyTestZmqEA.mq4:

Include/OTMql4:
OTLibLog.mqh
OTLibStrings.mqh
OTZmqProcessCmd.mqh
OTLibSimpleFormatCmd.mqh
OTLibJsonFormat.mqh
OTLibPy27.mqh
OTPyChart.mqh