Visual Studio 2019 C++ DLL strategy error

Examples step by step how to make your own automated strategy or user indicator
Message
Author
plasmon
Posts: 14
Joined: Mon Apr 15, 2013 2:45 pm

Visual Studio 2019 C++ DLL strategy error

#1 Postby plasmon » Sun Jan 26, 2020 3:18 pm

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 17439 times

FX Helper
Posts: 1479
Joined: Mon Apr 01, 2013 3:55 am

Re: Visual Studio 2019 C++ DLL strategy error

#2 Postby FX Helper » Mon Jan 27, 2020 7:45 am

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

FX Helper
Posts: 1479
Joined: Mon Apr 01, 2013 3:55 am

Re: Visual Studio 2019 C++ DLL strategy error

#3 Postby FX Helper » Mon Jan 27, 2020 7:47 am

I've attached a files with correct changes
Attachments
ObjectsTest.zip
(11.06 KiB) Downloaded 227 times

plasmon
Posts: 14
Joined: Mon Apr 15, 2013 2:45 pm

Re: Visual Studio 2019 C++ DLL strategy error

#4 Postby plasmon » Tue Jan 28, 2020 9:19 am

Thanks so much! I'll try this out.

plasmon
Posts: 14
Joined: Mon Apr 15, 2013 2:45 pm

Re: Visual Studio 2019 C++ DLL strategy error

#5 Postby plasmon » Fri Jan 31, 2020 1:41 pm

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.


Return to “Programming lessons”

Who is online

Users browsing this forum: No registered users and 10 guests