Page 1 of 1

Visual Studio 2019 C++ DLL strategy error

Posted: Sun Jan 26, 2020 3:18 pm
by plasmon
Hi all,

I'm trying to build dlls to pull into FX tester 4. I'm trying to make them in C++ and have built the strategy in Visual Studio 2019, but I keep getting the following error:

Severity Code Description Project File Line Suppression State
Error C1010 unexpected end of file while looking for precompiled header. Did you forget to add '#include "pch.h"' to your source? Dll1 C:\ForexTester2\Examples\Strategies\C++\ObjectsTest.cpp 144

I also get a number of other parameter related errors. I have added TechnicalFunctions.h, StrategyInterfaceUnit.h and also tried it with and without pch.h, but nothing seems to work, could anyone please advise? This is the screenshot:

C++ DLL strategy error.PNG
C++ DLL strategy error.PNG (108.14 KiB) Viewed 17495 times

Re: Visual Studio 2019 C++ DLL strategy error

Posted: Mon Jan 27, 2020 7:45 am
by FX Helper
Disable pch in project settings:
1. Project Menu -> Properties -> Configuration Properties -> C/C++ -> Precompiled Headers -> Precompiled Header set to "Not Using Precompiled Headers"
In StrategyInterfaceUnit.h change lines:
2.

Code: Select all

#define PChar char*
to

Code: Select all

#define PChar const char*

3.

Code: Select all

EXPORT void __stdcall ReplaceStr(PChar& dest, PChar source)
to

Code: Select all

EXPORT void __stdcall ReplaceStr(char*& dest, PChar source)

4.

Code: Select all

dest = (PChar)malloc(strlen((char*)source) + 1);
to

Code: Select all

dest = (char*)malloc(strlen((char*)source) + 1);

5.

Code: Select all

PChar IndicatorNameEx = (PChar)malloc(strlen(IndicatorName) + 4 + 1);
to

Code: Select all

char* IndicatorNameEx = (char*)malloc(strlen(IndicatorName) + 4 + 1);

6.

Code: Select all

#define EXPORT __declspec(dllexport)
to

Code: Select all

#define EXPORT extern "C" __declspec(dllexport)

7.

Code: Select all

EXPORT TInterfaceProcRec IntrfProcsRec;
to

Code: Select all

extern "C" { __declspec(dllexport) TInterfaceProcRec IntrfProcsRec; }

In StrategyInterfaceUnit.h:
8. insert

Code: Select all

#pragma warning (disable : 4996)
after the line

Code: Select all

#include <stdio.h>

9. insert

Code: Select all

#pragma comment(linker, "/EXPORT:ReplaceStr=_ReplaceStr@8")
before the line

Code: Select all

EXPORT void __stdcall ReplaceStr(char*& dest, PChar source)

In ObjectsTest.cpp change lines:
10.

Code: Select all

PChar Currency = NULL;
to

Code: Select all

char* Currency = NULL;

11.

Code: Select all

char* names[] = {"Line0", "Line1", "Line2", "Line3", "Fibo1",
to

Code: Select all

const char* names[] = {"Line0", "Line1", "Line2", "Line3", "Fibo1",

In ObjectsTest.cpp remove all occurances of

Code: Select all

__stdcall

Re: Visual Studio 2019 C++ DLL strategy error

Posted: Mon Jan 27, 2020 7:47 am
by FX Helper
I've attached a files with correct changes

Re: Visual Studio 2019 C++ DLL strategy error

Posted: Tue Jan 28, 2020 9:19 am
by plasmon
Thanks so much! I'll try this out.

Re: Visual Studio 2019 C++ DLL strategy error

Posted: Fri Jan 31, 2020 1:41 pm
by plasmon
Hi,

I tried this and made some adjustments, e.g. providing the full path to the header files seemed to do the trick, but I am now getting a 'E0311 cannot overload functions distinguished by return type alone' error, which I think implies the compiler cannot distinguish between two methods that are trying to do the same thing. I can't seem to attach the files even if they are zipped, I'd be grateful if anyone could help with regards to what else needs to be corrected and could try to arrange to send the files somehow.

Thanks again.