Crashing when integration with dll

Questions about MultiCharts and user contributed studies.
capgain
Posts: 63
Joined: 14 Apr 2008
Been thanked: 3 times

Crashing when integration with dll

Postby capgain » 19 Jan 2009

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!

capgain
Posts: 63
Joined: 14 Apr 2008
Been thanked: 3 times

Re: Crashing when integration with dll

Postby capgain » 20 Jan 2009

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

User avatar
Marina Pashkova
Posts: 2758
Joined: 27 Jul 2007

Re: Crashing when integration with dll

Postby Marina Pashkova » 21 Jan 2009

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!
Hi capgain,

When you say 'it crashes', are you talking about the dll or about MultiCharts?

User avatar
Marina Pashkova
Posts: 2758
Joined: 27 Jul 2007

Re: Crashing when integration with dll

Postby Marina Pashkova » 21 Jan 2009

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
Hi capgain,

Yes, the best way to pass a string from PowerLanguage to a C++ dll is to declare it as LPSTR.


Return to “MultiCharts”