Visual Studio C++ DLL Template

How to create strategies and indicators
Message
Author
imamushroom
Posts: 22
Joined: Wed Jan 20, 2016 2:52 pm

Visual Studio C++ DLL Template

#1 Postby imamushroom » Sun Aug 06, 2017 1:08 am

Here's a blank C++ DLL template that Forex Tester Support sent me after having difficulties setting the correct settings in Visual Studio 2017 Community. The file is too large to upload to the forum so have place it here: http://www.filedropper.com/forextesterdll

badasstrader
Posts: 6
Joined: Tue Aug 22, 2017 10:51 am

Re: Visual Studio C++ DLL Template

#2 Postby badasstrader » Sun Sep 10, 2017 11:23 am

Hello,

I think I'm going crazy trying to compile the lesson 1 DLL with Visual Studio 2017 Community. Linking is hell !
I'd like to use your template but I don't know how to get it, the link send me to the home page of filedropper.

christoff
Posts: 44
Joined: Thu Nov 09, 2006 2:29 am

Re: Visual Studio C++ DLL Template

#3 Postby christoff » Thu Sep 21, 2017 1:43 am

badasstrader wrote:Hello,

I think I'm going crazy trying to compile the lesson 1 DLL with Visual Studio 2017 Community. Linking is hell !
I'd like to use your template but I don't know how to get it, the link send me to the home page of filedropper.


Yeah same problem when I tried. Send me to home page as well

beno
Posts: 4
Joined: Tue Feb 13, 2018 7:46 pm

Re: Visual Studio C++ DLL Template

#4 Postby beno » Tue Feb 13, 2018 9:21 pm

To get lesson 1 working in an Empty Project on Visual Studio 2017, i had to do 2 things:

Edit Project Properties / Configuration Properties / C/C++ / Preprocessor / Preprocessor Definitions - Add _CRT_SECURE_NO_WARNINGS
Edit Project Properties / Configuration Properties / C/C++ / Command Line / Additional Options - Add /Zc:strictStrings-

jpygbp
Posts: 1
Joined: Sat Jun 03, 2017 2:47 pm

Re: Visual Studio C++ DLL Template

#5 Postby jpygbp » Wed Jul 11, 2018 9:34 am

Here is my batch file if you have any suggestions. I will upload a new version shortly to fix a few includes that are needed.

REM ////////////////////////////////////
REM batch file for Visual Studio Builds
REM ////////////////////////////////////
REM
@echo off
set CommonCompilerFlags=-Zi /Wv:18
set CommonLinkerFlags= /LD
call "C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Auxiliary\Build\vcvarsall.bat" x64
@echo on
mkdir "%~dp0build"
pushd "%~dp0build"
cl %CommonCompilerFlags% ../*.cpp %CommonLinkerFlags%
popd

KevinTester
Posts: 3
Joined: Fri Feb 01, 2019 7:57 am

Re: Visual Studio C++ DLL Template

#6 Postby KevinTester » Wed Feb 20, 2019 10:53 am

Couple of other things that you will need to do if you're not familiar with VS2017.

When you create a new project in VS it by default adds, #include "stdafx.h". The file "stdafx.h" includes inside itself "windows.h". Don't try to change that, way too many things are dependent the other stuff in "stdafx.h.
The following steps should get you to be able to build the .dll, assuming that your code has no errors in it.

1. Project Properies: C/C++ -> Preprocessor -> Preprocessor Definitions add _CRT_SECURE_NO_WARNINGS
2. Project Properies: C/C++ -> Command Line -> add /Zc:strictStrings-
3. Project Properies: Linker -> Input -> Module Definition File add correct Something.def
4. In dllmain.cpp comment out everything except #include "stdafx.h"

Most of the linker errors are due to the fact that dllmain.cpp provides a default entry point for the .dll. How ever, the ForexTester supplied file StrategyInterfaceUnit.h already defines the needed entry point. That's why you comment out all of the stuff in dllmain.cpp except the #include "stdafx.h".

windsurfingstew
Posts: 5
Joined: Fri Jun 23, 2017 6:55 am

Re: Visual Studio C++ DLL Template

#7 Postby windsurfingstew » Wed Nov 27, 2019 8:34 am

Does ForexTester4 have the same API, or have they not added API features?

windsurfingstew
Posts: 5
Joined: Fri Jun 23, 2017 6:55 am

Re: Visual Studio C++ DLL Template

#8 Postby windsurfingstew » Wed Nov 27, 2019 9:35 am

I tried this. One further thing I had to do is:

5. Project Properties: C/C++ -> Precompiled Headers -> Precompiled Headers -> Not Using Precompiled Headers

If I don't do this I get messages that it can't find them. I'm not entirely sure why this works, and perhaps there is a better solution, but it gets me over the line.

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

Re: Visual Studio C++ DLL Template

#9 Postby FX Helper » Thu Nov 28, 2019 6:20 am

windsurfingstew wrote:Does ForexTester4 have the same API, or have they not added API features?


Yes, FT4 version has the same API files, they can be found in C:\ForexTester4\Examples folder by default.


Return to “FT API”

Who is online

Users browsing this forum: No registered users and 3 guests