custom dll for multicharts  [SOLVED]

Questions about MultiCharts and user contributed studies.
idnotbe
Posts: 10
Joined: 16 Mar 2010
Has thanked: 3 times

custom dll for multicharts

Postby idnotbe » 02 Aug 2013

To test custom dll, i built the following C++ codes. (Win7 32bit, VS 2012 Express)

Code: Select all

// DllTest.h

#pragma once

__declspec(dllexport) int __stdcall add(int a, int b);

Code: Select all

// DllTest.cpp

#include "stdafx.h"

#include "DllTest.h"

int __stdcall add(int a, int b)
{
return a+b;
}

Code: Select all

// indicator (power language)

external: "C:\Users\xxx\Desktop\DllTest\Debug\DllTest.dll", int, "add", int, int;

messagelog(add(1,2));
when i insert the indicator, i got

Error in study "DllTest"::Can't find function "add" in dll.

what's wrong?
I can view the "add" function through the application called "DLL EXPORT VIEWER"
Attachments
DllTest.zip
(1.94 MiB) Downloaded 207 times

Dru
Posts: 107
Joined: 28 Aug 2007
Has thanked: 4 times
Been thanked: 171 times

Re: custom dll for multicharts  [SOLVED]

Postby Dru » 05 Aug 2013

Code: Select all

// DllTest.h

#pragma once

extern "C" __declspec(dllexport) int __stdcall add(int a, int b);

idnotbe
Posts: 10
Joined: 16 Mar 2010
Has thanked: 3 times

Re: custom dll for multicharts

Postby idnotbe » 05 Aug 2013

i solved the problem.

i think it's because of the compiler or the platform settings in visual studio.
i am developing on 64bit environments and when i set the target platform to 64bit in visual studio 2012 express, it works.

anyway, thanks dru.

gnimnek168
Posts: 2
Joined: 05 Nov 2015

Re: custom dll for multicharts

Postby gnimnek168 » 30 Nov 2015

Hi idnotbe:

I had the same problem as you.
My IDE is Visual Studio 2015 Community, Windows 10-64bit, Multicharts 64bit 9.1.

I had changed the build platform to x64, but the error is same.
Can you attach your new solution file for this testdll ?

Thanks for your kindly share~

gnimnek168
Posts: 2
Joined: 05 Nov 2015

Re: custom dll for multicharts

Postby gnimnek168 » 30 Nov 2015

The problem I had solved. :)

Because I use the project for DllExport & DllImport,and then must expose the methods by extern "C" keyword (powerlanage can call the exposed methods). the below definition code :

MCExtfuncs.h

Code: Select all

#pragma once

#ifdef MCExtFuncs_API_EXPORT
#define MCExtFuncs_API __declspec( dllexport )
#else
#define MCExtFuncs_API __declspec( dllimport )
#endif

#include <string>

#ifdef __cplusplus
extern "C" {
#endif
MCExtFuncs_API void MCWrite(std::string FQDN);
#ifdef __cplusplus
}
#endif


Return to “MultiCharts”