DLL in 64 bit MC

Questions about MultiCharts and user contributed studies.
ManuelVene
Posts: 17
Joined: 12 Jun 2015
Been thanked: 1 time

DLL in 64 bit MC

Postby ManuelVene » 19 Jul 2018

Hello everyone,

I've tried everything to get a dll to work, with no success whatsoever. To my knowledge, all threads about this topic are at least 3 to 4 years old, and it's difficult ti find anything really replicable on current softwares.
The problem: write a dll, for MC64, with a simple function in it, and make it work. Probably to many of you this will look like a trivial task, but whatever I did, after reading virtually every thread and manual out there, I keep getting the the error "Can't find the dll "name.dll"".
Now, the dll is where it should and moving it somewhere else is useless. I came to the conclusion that there's some compatibility issue, bitness may be an example but I made sure to compile in 64.

I can't be the only one that is having problems in doing this, so I think it would be useful to have an updated thread on the matter.
Just as a starting point, here is my code:

PL reference:

Code: Select all

external: "mylib.dll", double, "add", double, double;
Then there are the two components of the library: a .cpp for the body of functions, and the .def file for exports.
They will look something like this.

The body:

Code: Select all

#include "stdafx.h"

#include "mylib.h"

#include <comdef.h>

double __stdcall add(double _1, double _2){
return (_1 + _2);
}
The .def:

Code: Select all

LIBRARY "mylib"
EXPORTS
add
The header .h file completes the picture.

The thing is compiled using Visual Studio 2017 for x64 platforms. Obviously there's something wrong with this, and the library results as not found.
Is there anyone capable of showing an example of working dll source code for MC64?

Few clarifications:
  • - The dll content is kept as simple as possible to avoid a superposition of multiple mistakes
    - The dll is where it should, in the installation folder
    - Moving it somewhere else and explicitly reference the whole path doesn't make any difference
    - Dlls that are officially provided by MC work properly, ELCollections is an example that I tried
    - The dll is needed, so, in this case, "code the PL equivalent" is not a viable solution. Just assume a dll is needed.

hughesfleming
Posts: 275
Joined: 22 Apr 2014
Has thanked: 70 times
Been thanked: 72 times

Re: DLL in 64 bit MC

Postby hughesfleming » 19 Jul 2018

You might try an earlier version of Visual Studio. I did experiment with this for a while and ended up using CodeTyphon x64 which is based on Free Pascal. Not everyones first choice but it was the most straight forward of all the options I tried with or without PLkit. VS worked as did PureBasic with various degrees of difficulty.

I also struggled with documentation and examples at the time. mtompkins has an example on GitHub that might be helpful.

https://github.com/mtompkins/openAlgo/t ... cfunctions

ManuelVene
Posts: 17
Joined: 12 Jun 2015
Been thanked: 1 time

Re: DLL in 64 bit MC

Postby ManuelVene » 19 Jul 2018

I will for sure dig into the repository you linked! First time I see that one. I'll see as well if CodeTyphon x64 helps


Return to “MultiCharts”