basic 'hello world' dll

 

I am trying to create a basic hello world dll using codeblocks and metatrader4 and trying to do it in a striped version. my compile .dll and .def are in the same dir as the .mq4 file.

in file test.mq4

#property link      "https://www.mql5.com"
#property version   "1.00"
#property strict
#import "C:\Users\Brad2\AppData\Roaming\MetaQuotes\Terminal\038983A63A5CE68161CBF3B0C5B3FC6A\MQL4\Experts\gimmeDLL.dll"
      void HelloWorld define;

void OnStart()
  {

    HelloWorld();

  }

in the main.cpp of the dll

#include <iostream>
using namespace std;

#define _DLLAPI extern "C"__declspec(dllexport)

void HelloWorld()
{
    cout << "Hello, World" << endl;
}

error

'OnStart' - #import was not closed  marketDump.mq4  15  6
'HelloWorld' - function not defined marketDump.mq4  20  1
 
tunage:I am trying to create a basic hello world dll using codeblocks
#import "gimmeDLL.dll"
Importing Function (#import) - MQL4 Documentation

#import "file_name"
    func1 define;
    func2 define;
    ...
    funcN define;
#import           

 

I am not making an indicator. I am making an actual driver.
I used "hello world" in a dll file for a reason. I just need 'hello world' to start.
No where in that doc does it address the core communication of mt4 (the start button specifically) and a dll file.

 
tunage:No where in that doc does it address the core communication of mt4 (the start button specifically) and a dll file.
MQL4\Scripts\Examples\DLL
 
WHRoeder:
tunage:No where in that doc does it address the core communication of mt4 (the start button specifically) and a dll file.
MQL4\Scripts\Examples\DLL


That got me really close, but I am still missing something really foolish  :(

 

in file test.mq4

#property copyright "Copyright 2014, MetaQuotes Software Corp."
#property link      "https://www.mql5.com"
#property version   "1.00"
#property strict
#import "gimmeDLL.dll"
   string GetStringValue(string) define;
#import

void OnStart()
  {
   GetStringValue();

  }

in the main.cpp of the dll

#define WIN32_LEAN_AND_MEAN  // Exclude rarely-used stuff from Windows headers
#include <windows.h>
#include <stdlib.h>
#include <stdio.h>
#include <iostream>
using namespace std;

#define MT4_EXPFUNC __declspec(dllexport)

void MT4_EXPFUNC GetStringValue()
  {
   cout << "Hello, World" << endl;
  }

in gimmeDLL.def I have

LIBRARY gimmeDLL

EXPORTS
    GetStringValue

error

'define' - semicolon expected   marketDump.mq4  6   34
'define' - declaration without type marketDump.mq4  6   34 

'GetStringValue' - wrong parameters count marketDump.mq4 11 4 

 
tunage: That got me really close, but I am still missing something really foolish  :(
string GetStringValue(string) define;
:
void MT4_EXPFUNC GetStringValue()
  1. Look at the doc again. Where in the examples do you see "define;"?
  2. What do you declare GetStringValue requires as a parameter? What does it actually take?
 
WHRoeder:
tunage: That got me really close, but I am still missing something really foolish  :(
  1. Look at the doc again. Where in the examples do you see "define;"?
  2. What do you declare GetStringValue requires as a parameter? What does it actually take?


I apologize, I should of mentioned I get the same error with  string GetStringValue(string) define; or  string GetStringValue() define;

I have been mix matching every which way to try and figure out what semicolon it's talking about. It's driving me nutz.

It takes nothing, just print Hello World. 

I took the sample dll and chopped and forgot to leave out the string in the post. But same error either way. 

 
Look at the doc again. Where in the examples do you see "define;"?
bool   SetArrayItemValue(double &arr[],int,int,double)         ;
double GetRatesItemValue(double &rates[][6],int,int,int)      ;
#import
 Now answer the question.
string GetStringValue(string) define;
Reason: