Download MetaTrader 5

DLL error 126

To add comments, please log in or register
shaytoder
9
shaytoder  
Hi,

i'm trying to use a DLL from my EA in MT4 (Build 1010)
i wrote a DLL using C++ with VS 2015 
but i am keep getting Error 126
i tried to put the DLL in the Data folder (Build 600+ folders):
C:\Users\XXX\AppData\Roaming\MetaQuotes\Terminal\XXX\MQL4\Libraries
and i tried to put it in a different folder, no luck, i keep getting 126 error
my DLL is complied to 32 bit.

my DLL code is - 
stdafx.h :
#pragma once
#include "targetver.h"
#define WIN32_LEAN_AND_MEAN             // Exclude rarely-used stuff from Windows headers
#include <windows.h>
//#define MT4_EXPFUNC __declspec(dllexport) // i tried this line also
#define MT4_EXPFUNC extern "C" __declspec (dllexport)

myDLL.cpp :
#include "stdafx.h"
#include <complex>

MT4_EXPFUNC int mySum(int a, int b)
{
return a + b;
}

MT4_EXPFUNC double  myPower(double a, double b)
{
return std::pow(a, b);
}


my EA Code is :
myEA.mq4 :
#import "myDLL.dll"
   int mySum(int,int);
   double myPower(double, double);
#import

int OnInit()
  {
   Print("Returned from Sum in init module ",mySum(1,2));
   Print("Returned from Power in init module ",myPower(2,2));
   
   return(INIT_SUCCEEDED);
  }

void OnDeinit(const int reason)
  { 
  }

void OnTick()
  {
   Print("Returned from Sum in start module ",mySum(3,4));
   Print("Returned from Power in start module ",myPower(3,4));   
  }

Thanks,
Shay  
Marco vd Heijden
Moderator
4798
Marco vd Heijden  

126

Variable name is too long (> 250 characters)


The error is self explanatory you are handling too large variables so either increase variable capacity or decrease variable input.

Also make sure the file path isn't too long.

shaytoder
9
shaytoder  

no, error 126 is DLL not found

anyway - i solved it :

i compile it toRELEASE instead of DEBUG 

and in debug mode, i need theVisual C++ Redistributable (as i understood from searching the web)


Shay

To add comments, please log in or register