.....Static class members do not need to be initialized explicitly globally, they will be initialized automatically when the program is loaded. ......
No changes were made in the class code, and the error wasn't there before.
//+------------------------------------------------------------------+//| Class CCanvas |//| Usage: class for working with a dynamic resource |//+------------------------------------------------------------------+class CCanvas
{
private:
uint m_style; // line style templateuint m_style_idx; // variable - current index of bit in line style templatestaticuintm_default_colors[9]; // default colorsprotected:
I've started to transfer my developments from mt4 to mt5. For the first time I have faced a problem with loading DLL. It compiles well but when I start the indicator. Error "cannot open dll". No more error messages. I've read all the articles and placed it all the way: Library in directory ...\Terminals\MetaTrader 5\MQL5\Libraries
//+------------------------------------------------------------------+//| Test MySQL.mq5 |//| me |//| no |//+------------------------------------------------------------------+#property copyright"me"#property link"no"#property version"1.00"#property indicator_separate_window#import "libmysql.dll"int mysql_init(int db);
int mysql_errno(int TMYSQL);
int mysql_real_connect( int TMYSQL,string host,string user,string password, string DB,int port,int socket,int clientflag);
int mysql_real_query(int TMSQL,string query,int length);
void mysql_close(int TMSQL);
#import
int i = 0;
int mysql;
string query;
//+------------------------------------------------------------------+//| Custom indicator initialization function |//+------------------------------------------------------------------+intOnInit()
{
//--- indicator buffers mappingPrint(GetLastError());
mysql = mysql_init(mysql);
if (mysql!=0) Print("allocated");
string host="localhost";
string user="root";
string password="1111";
string DB="fxdb";
int clientflag =0;
int port = 3306;
string socket="";
int res = mysql_real_connect(mysql,host,user,password,DB,port,socket,clientflag);
int err = GetLastError();
if (res == mysql) Print("connected");
elsePrint("error = ",mysql," ",mysql_errno(mysql)," ");
//До этой строки все правильно работает.
i++;
StringConcatenate(query, "INSERT INTO ",
//CharToStr(039),"test",
//CharToStr(039), " (",
//CharToStr(039), "ID",
//CharToStr(039), ", ",
//CharToStr(039), "text",
//CharToStr(039), ") VALUES (",
CharToString(039),
DoubleToString(i,0),
CharToString(039),
", ",
CharToString(039),
"testtext",
CharToString(039),
")"
);
Print("i = ", i);
Print(query);
int length = StringLen(query);
mysql_real_query(mysql,query,length);
int myerr=mysql_errno(mysql);
if (myerr>0)Print("error=",myerr); elsePrint(i, "good");
return(0);
//---return(INIT_SUCCEEDED);
}
//+------------------------------------------------------------------+//| Custom indicator iteration function |//+------------------------------------------------------------------+intOnCalculate(constint rates_total,
constint prev_calculated,
constdatetime &time[],
constdouble &open[],
constdouble &high[],
constdouble &low[],
constdouble &close[],
constlong &tick_volume[],
constlong &volume[],
constint &spread[])
{
//---//--- return value of prev_calculated for next callreturn(rates_total);
}
//+------------------------------------------------------------------+//| TradeTransaction function |//+------------------------------------------------------------------+voidOnTradeTransaction(constMqlTradeTransaction& trans,
constMqlTradeRequest& request,
constMqlTradeResult& result)
{
//---
}
//+------------------------------------------------------------------+
.....Static class members don't need to be initialized explicitly globally, they will be initialized automatically at program startup. ......
The rest of my suggestions are devoted to running the program in the presence of this bug. The intermediate initialization performs this function, so you can work without waiting for the bug fixing.
This is a typical scheme of my actions in such situations.
The path to copying can be seen through MetaEditor, taking the properties of the MQL5 folder in the navigator, the path is written in the "Location" field. And then copy your DLL in the folder [path]\MQL5\Libraries\.
Dear administration, something is wrong with the metaQuotes-DEMO server
Says in the log : 2013.08.01 11:58:35Network'1449777': connection to MetaQuotes-Demo lost
The account has been banned by the trading server for excessive trading activity. The trading platform is protecting itself and disabling those accounts that mindlessly send trade requests on every tick.
You can see the copying path in MetaEditor, taking the properties of the MQL5 folder in the navigator, the path is written in the location column. And then copy your DLL in the folder [path]\MQL5\Libraries\
Yes, but as I wrote, I already copied libmysql [path]\MQL5\Libraries\
Al_key: Yeah, but like I wrote, I already copied libmysql [path]\MQL5\Libraries\.
I go to the meta editor and open the properties of MQL5 folder, but there is some path that is not associated with my terminal folder. Will it always be like this from now on, or can I adjust it? By the way, I did so and copied everything. Still the same error.
Ok, new edit to the post. Everything seems to be working, a bunch of other errors, I'll look into it now. And still how to make a standard folder for indices and EAs and other data. Will the /portable switch help?
Allow the use of cookies to log in to the MQL5.com website.
Please enable the necessary setting in your browser, otherwise you will not be able to log in.
You are signed in. Two-factor authentication has been disabled. Set it up again and scan a new QR code, or continue with two-factor authentication disabled.
Bild 842/64 bit. When declaring a canva:
an error appears:
Unresolved static variable 'CCanvas::m_default_colors'
Everyone seems to have one.
Try initializing explicitly:
Although this seems to be a bug, according to the documentation. https://www.mql5.com/ru/docs/basis/oop/staticmembers
.....Static class members do not need to be initialized explicitly globally, they will be initialized automatically when the program is loaded. ......
No changes were made in the class code, and the error wasn't there before.
It seems to be the same for everyone.
No changes have been made to the class code, and there was no such error before.
This is how it compiles:
Hello! Help me solve a problem.
I've started to transfer my developments from mt4 to mt5. For the first time I have faced a problem with loading DLL. It compiles well but when I start the indicator. Error "cannot open dll". No more error messages. I've read all the articles and placed it all the way: Library in directory ...\Terminals\MetaTrader 5\MQL5\Libraries
this is how it compiles:
Yes, but what's all this for?
In the class constructor, this array is also initialized with new values, overwriting the ones you suggested.
Anyway, like this:
Compiles without errors. And let developers tell the sense of entering m_default_colors in the help.Yes, but what for?
In the class constructor this array is also initialized with new values, wiping out the ones you suggest.
Anyway, that's it:
Compiles without errors. And let developers can tell the meaning of m_default_colors in the help.I told you it was a bug, so go to servicedesk with it.
Although, judging by the documentation, this is a bug. https://www.mql5.com/ru/docs/basis/oop/staticmembers
.....Static class members don't need to be initialized explicitly globally, they will be initialized automatically at program startup. ......
The rest of my suggestions are devoted to running the program in the presence of this bug. The intermediate initialization performs this function, so you can work without waiting for the bug fixing.
This is a typical scheme of my actions in such situations.
MetaDriver:
Intermediate initialization performs this function, so you can work without waiting for the bug to be fixed.
This is a typical scheme of my actions in such situations.
And my actions too. Thank you.
And Service Desk reads and re-reads this thread, so they will fix it.
Al_key:
Error "cannot open dll". No further messages.
The terminal does not find your DLL.
The path to copying can be seen through MetaEditor, taking the properties of the MQL5 folder in the navigator, the path is written in the "Location" field. And then copy your DLL in the folder [path]\MQL5\Libraries\.
Dear administration, something is wrong with the metaQuotes-DEMO server
Says in the log : 2013.08.01 11:58:35 Network '1449777': connection to MetaQuotes-Demo lost
The terminal does not find your DLL.
You can see the copying path in MetaEditor, taking the properties of the MQL5 folder in the navigator, the path is written in the location column. And then copy your DLL in the folder [path]\MQL5\Libraries\
Yeah, but like I wrote, I already copied libmysql [path]\MQL5\Libraries\.
I go to the meta editor and open the properties of MQL5 folder, but there is some path that is not associated with my terminal folder. Will it always be like this from now on, or can I adjust it? By the way, I did so and copied everything. Still the same error.
Ok, new edit to the post. Everything seems to be working, a bunch of other errors, I'll look into it now. And still how to make a standard folder for indices and EAs and other data. Will the /portable switch help?