I am having a problem when I am trying to integrate Multicharts with DLL. Please take a look at this:
- It is a simple dll calculating cube (example)
This is my cpp file
--------
extern "C"
int cube(int num) {
return num * num * num;
}
--------
This is the .h filr
--------
#ifndef CPPDLL_H
#define CPPDLL_H
extern "C"
int cube(int num);
#endif //CPPDLL_H
---------
This is the .def file
---------
EXPORTS
cube
It compiles fine into a dll. In the indicator, I do this:
----------
DefineDLLFunc: "C:\debug\cppdll.DLL", int, "cube", int;
cube( 1);
This also works fine. But if I do this:
------------
cube( 1);
cube( 1);
cube( 1);
cube( 1);
cube( 1);
cube( 1);
It crashes. I tried with a different dll (with functionality that I need) and there too it crashes when I call a dll function repeatitively.
Can anyone point what might be happening ...
Thanks!
Crashing when integration with dll
Re: Crashing when integration with dll
The problem appears to be fixed. I tried several things but what appears to work is have the function name in the dll in all uppercase letters.
What is the best way to pass string from easylanguage to C++ dll (to declare it as LPSTR ?) Thanks
What is the best way to pass string from easylanguage to C++ dll (to declare it as LPSTR ?) Thanks
- Marina Pashkova
- Posts: 2758
- Joined: 27 Jul 2007
Re: Crashing when integration with dll
Hi capgain,I am having a problem when I am trying to integrate Multicharts with DLL. Please take a look at this:
- It is a simple dll calculating cube (example)
This is my cpp file
--------
extern "C"
int cube(int num) {
return num * num * num;
}
--------
This is the .h filr
--------
#ifndef CPPDLL_H
#define CPPDLL_H
extern "C"
int cube(int num);
#endif //CPPDLL_H
---------
This is the .def file
---------
EXPORTS
cube
It compiles fine into a dll. In the indicator, I do this:
----------
DefineDLLFunc: "C:\debug\cppdll.DLL", int, "cube", int;
cube( 1);
This also works fine. But if I do this:
------------
cube( 1);
cube( 1);
cube( 1);
cube( 1);
cube( 1);
cube( 1);
It crashes. I tried with a different dll (with functionality that I need) and there too it crashes when I call a dll function repeatitively.
Can anyone point what might be happening ...
Thanks!
When you say 'it crashes', are you talking about the dll or about MultiCharts?
- Marina Pashkova
- Posts: 2758
- Joined: 27 Jul 2007
Re: Crashing when integration with dll
Hi capgain,The problem appears to be fixed. I tried several things but what appears to work is have the function name in the dll in all uppercase letters.
What is the best way to pass string from easylanguage to C++ dll (to declare it as LPSTR ?) Thanks
Yes, the best way to pass a string from PowerLanguage to a C++ dll is to declare it as LPSTR.