Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update "How to build" in README #222

Open
eabase opened this issue Nov 2, 2020 · 13 comments
Open

Update "How to build" in README #222

eabase opened this issue Nov 2, 2020 · 13 comments

Comments

@eabase
Copy link
Contributor

eabase commented Nov 2, 2020

Please update the building section of your README to include more details.

The following really can't get anyone started.

How to Build Solution

The project is supported by Visual Studio 2017 and requires WIX Tools (http://wixtoolset.org/).

To make an API for MetaTrader4 use MtApiInstaller and for MetaTrader5 use MtApi5Installer. 
All installers will be placed in the folder "[root]\build\installers" and all *.dll files will be 
placed in "[root]\build\products". MQL files have been build to ex4 and stored into 
folders "mq4" for MetaTrader and "mq5" for MetaTrader5. They are ready to be used in
 terminals. Changing the source code of MQL expert requires recompilation with MetaEditor. 
Resulting in the need to copy files "hash.mqh" and "json.mqh" to the MetaEditor include folder.

(Yes, I installed VS and WIX, then what?)

@eabase
Copy link
Contributor Author

eabase commented Nov 2, 2020

Here's a start to a Wiki...


Installing WIX for mtapi

  1. You need to have Visual Studio already installed.

  2. Make sure you install one of the latest (3.14+) development releases of the wixtoolset.
    (If you use an older installer you will have to install the ancient .NET 3.5 framework, and that I am sure you will regret, if you do!)

  3. Run the installer and wait for completion or for asking to also install the VS extensions.

2020-11-02_14-05-43

  1. Install the WiX Toolset Visual Studio Extension depending on your VS version.
    For example, if you use VS 2017, go here or download from their GitHub, releases.

  2. Done.

@eabase
Copy link
Contributor Author

eabase commented Nov 4, 2020

From forum channel:

To build the solution for MT4 you need to choose configuration x86 and start build for MtApiInstaller.
It will build all projects related to MT4: MtApi, MTApiService, MTConnector.
MtApiBootstrapper is an exe wrapper for installer that also contains the vc_redist libraries.

@eabase
Copy link
Contributor Author

eabase commented Nov 12, 2020

I think I need some more help here.

After having already installed VS2017 + WIX dep's as shown above, and having done:
git clone https://github.com/vdemydiuk/mtapi/

What are the next steps to import and compile the project (when using VS Code)?

vdemydiuk added a commit that referenced this issue Nov 12, 2020
@vdemydiuk
Copy link
Owner

I made some updates in readme.
I will fill more information about project time to time.

@eabase
Copy link
Contributor Author

eabase commented Nov 13, 2020

WIP 🚧

What's a better place to test README markup files, but in an issue post!?


How to Build Solution

To build the solution for MT4, you need to choose the configuration to build for x86
and start with building the MtApiInstaller. This will build all projects related to MT4:

  • MtApi
  • MTApiService
  • MTConnector

For building the solution for MT5, you need to choose the configuration to build for x64 (or x86 for the 32-bit MT5)) and start build MtApi5Installer. This will build all projects related to MT5:

  • MtApi5
  • MTApiService
  • MT5Connector

All binaries are placed in the project root folder, in the build directory: ../build/.
The installers (*.msi, *.exe) will be found under: ../build/installers/.
All the DLL library binaries (*.dll) in: ../bin/.

MQL files have been pre-compiled to *.ex4 and can be found in the repository here:

  • ..\mql4\
  • ..\mql5\

Changing the source code of the MQL Expert Advisor (EA), requires recompilation with MetaEditor.

Before you can recompile the EA, you need to add/place the following MQL library files, in the MetaEditor ../Include/ folder.

  • hash.mqh
  • json.mqh

The MetaEditor include folder is usually located here:

C:\Users\<username>\AppData\Roaming\MetaQuotes\Terminal\<terminal-hash>\MQL5\Include\.

Project Structure

  • MTApiService: (C#, .dll)
    The common engine communication project of the API. It contains the implementations of client and server sides.

  • MTConnector, MT5Connector: (C++/CLI, .dll)
    The libraries that are working as proxy between MQL and C# layers. They provides the interfaces.

  • MtApi, MtApi5: (C#, .dll)
    The client side libraries that are using in user's projects.

  • (MQL4/MQL5, .ex4)
    MT4 and MT5 Expert Advisors linked to terminal's charts. They executes API's functions and provides trading events.

  • MtApiInstaller, MtApi5Installer (WIX, .msi)
    The project's installers.

  • MtApiBootstrapper, MtApi5Bootstrapper (WIX, .exe)
    The installation package bundles. There are wrappers for installers that contains the vc_redist
    libraries (Visual C++ runtime) placed in [root]\vcredist.

Installation

Use the installers to setup all libraries automatically.

  • For MT4, use: MtApiInstaller_setup.exe
  • For MT5, use: MtApi5Installer setup.exe

MtApiBootstrapper and MtApi5Bootstrapper are installation package bundles that contain the installers and vc_redist Windows libraries. The installers place the MTApiService.dll into the Windows GAC (Global Assembly Cache) and copies MTConnector.dll and MT5Connector.dll into the Windows's system folder, whose location depend on your Windows OS. After installation, the MtApi.ex4 (or MtApi5.ex5) EA, must be copied into your Terminal data folder for Expert Advisors, which is normally located in: ../MQL5/Experts/.

To quickly navigate to the trading platform data folder, click: File >> "Open data folder" in your MetaTrader Terminal.

@eabase
Copy link
Contributor Author

eabase commented Nov 13, 2020

@vdemydiuk
just sent you PR for updating the README. Forgot to do it to the dev branch, but maybe you can handle it anyway?

@eabase
Copy link
Contributor Author

eabase commented Nov 13, 2020

PS. I am still not able to compile, using these instructions.
Can you provide some detail pelase?

  • Also, is .NET SDKs for Visual Studio 2017 needed?
  • Can VS 2019 be used?

@eabase
Copy link
Contributor Author

eabase commented Nov 13, 2020

🥵 --- ➡️ --- 🥇

Thanks to some amazing help by @vdemydiuk I have now been able to compile this whole project for MT4 on a Win8.1 & VS 2017. I will try to summarize the steps and procedures in this thread, and then we can clean it up and add it to a COMPILE.md or the Wiki.


First things first. make sure you have cloned the latest version of this repo.

  • Note: ❗
    Here I use a shallow clone, because I am not yet interested in making dev changes, just build the project.
    If you need to do dev and make PR's, you have to use a normal/full clone.
# cd D:\myDev\_gh_cloned\
#git clone --depth=1 --no-tags git@github.com:vdemydiuk/mtapi.git 	# ssh -- better
git clone --depth=1 --no-tags https://github.com/vdemydiuk/mtapi.git 	# http --faster
cd mtapi

Installation Instructions

Next Prepare yourself for Visual Studio 2019 (from now on just "VS"). (But here I use 2017.) You need to install a bunch, and I mean a lot of, yes too many, dependencies. Otherwise you will run into all sorts of weird stuff. So if you're new to VS, just make sure you have the latest updated version.

Click for a Surprise!

devenv_2020-11-13_20-39-14


  • Install Visual Studio 2019 from here.
  • Install the WIX stuff from above ...
  • Install the 2 .NET Framework's: .NET 4.8, .NET 4.7.2 and .NET Core (5.0) from here:
Click Me!

firefox_2020-11-13_20-31-59

firefox_2020-11-13_20-33-10

  • Fire up the Visual Studio Installer and install the following items:
Click Me!

vs_installershell_2020-11-13_21-02-48

vs_installershell_2020-11-13_19-39-17

  • Also make sure you install the C++/CLI package.

More interestingly you may also try to just import all the requirements I had, by clicking "Import Configuration" in the drop-down (as shown in the screenshot below). Save the following text/code into a file called .vsconf and import it.

Click Me!

vs_installershell_2020-11-13_21-56-43

➡️ Import This:

{
	"version": "1.0",
	"components": [
		"Microsoft.VisualStudio.Workload.ManagedDesktop",
		"Microsoft.VisualStudio.Workload.NativeDesktop",
		"microsoft.net.componentgroup.targetingpacks.common",
		"microsoft.componentgroup.blend",
		"microsoft.visualstudio.component.entityframework",
		"microsoft.visualstudio.component.diagnostictools",
		"microsoft.visualstudio.component.debugger.justintime",
		"microsoft.net.componentgroup.4.7.2.developertools",
		"microsoft.visualstudio.component.vc.diagnostictools",
		"microsoft.visualstudio.component.vc.cmake.project",
		"microsoft.visualstudio.component.vc.atl",
		"microsoft.visualstudio.component.vc.testadapterforboosttest",
		"microsoft.visualstudio.component.vc.testadapterforgoogletest",
		"microsoft.visualstudio.componentgroup.nativedesktop.win81",
		"microsoft.visualstudio.component.vc.cli.support",
		"microsoft.component.netfx.native",
		"microsoft.visualstudio.component.windows10sdk",
		"component.wixtoolset.visualstudioextension.dev15",
		"component.wixtoolset.visualstudioextension.schemas3",
		"component.wixtoolset.visualstudioextension.schemas4"
	]
}
  • Fire up Visual Studio and open the cloned project repo (mtapi), by clicking:
  1. [File] > Open > Project/Solution (or just type CTRL-SHIFT-o)
  2. Navigate to the path of your repo. For example: D:\myDev\_gh_cloned\mtapi\
  3. Select the solution file, named: MetaTraderApi_2017.sln.
    (Note that VS projects are also called solutions and have the file extension *.sln.)
Click Me!

devenv_2020-11-13_17-57-15

  • Now the project is imported, you need to adjust a few things:
  1. Retarget the project to use Win8.1 instead of Win10, if needed.
  2. Change to use 32-bit builds (for MT4) by default, as shown on top bar of VS.
  3. Select a Startup Project. Set to use: TestApiClientUI, also shown on top bar of VS.
  4. Select what to build in the Configuration Manager....
Click Me!

devenv_2020-11-13_21-22-19

devenv_2020-11-13_21-24-54

devenv_2020-11-13_19-47-57

devenv_2020-11-13_20-11-15

  • You are now ready to Build the project!
    Select: Solution 'MetaTraderApi_2017' (13 projects) and hit F6 or click the Build Solution button.
Click Me!

devenv_2020-11-13_21-33-38

🥇 DONE! 💖

@eabase
Copy link
Contributor Author

eabase commented Nov 13, 2020

The tree structure of all available DLL's, after a successful release build:

Click Me!
# tree --dirsfirst --prune -P *.dll ./
./
├── build
│   └── products
│       ├── Debug
│       │   ├── MT5Connector.dll
│       │   ├── MtApi.dll
│       │   ├── MTApiService.dll
│       │   ├── MTConnector.dll
│       │   └── Newtonsoft.Json.dll
│       └── Release
│           ├── MT5Connector.dll
│           ├── MtApi.dll
│           ├── MtApi5.dll
│           ├── MTApiService.dll
│           ├── MTConnector.dll
│           └── Newtonsoft.Json.dll
├── Examples
│   └── MatLab
│       └── AdvancedExample
│           └── DLL
│               └── MtApi5.dll
├── MtApi
│   └── obj
│       ├── Debug
│       │   └── MtApi.dll
│       └── Release
│           └── MtApi.dll
├── MtApi5
│   └── obj
│       └── Release
│           └── MtApi5.dll
├── MTApiService
│   └── obj
│       ├── Debug
│       │   └── MTApiService.dll
│       └── Release
│           └── MTApiService.dll
├── MtApiSetupActions
│   ├── bin
│   │   ├── Debug
│   │   │   ├── Microsoft.Deployment.WindowsInstaller.dll
│   │   │   ├── MtApiSetupActions.CA.dll
│   │   │   └── MtApiSetupActions.dll
│   │   └── Release
│   │       ├── Microsoft.Deployment.WindowsInstaller.dll
│   │       ├── MtApiSetupActions.CA.dll
│   │       └── MtApiSetupActions.dll
│   └── obj
│       └── x86
│           ├── Debug
│           │   ├── MtApiSetupActions.CA.dll
│           │   └── MtApiSetupActions.dll
│           └── Release
│               ├── MtApiSetupActions.CA.dll
│               └── MtApiSetupActions.dll
├── packages
│   ├── log4net.2.0.5
│   │   └── lib
│   │       ├── net10-full
│   │       │   └── log4net.dll
│   │       ├── net11-full
│   │       │   └── log4net.dll
│   │       ├── net20-full
│   │       │   └── log4net.dll
│   │       ├── net35-client
│   │       │   └── log4net.dll
│   │       ├── net35-full
│   │       │   └── log4net.dll
│   │       ├── net40-client
│   │       │   └── log4net.dll
│   │       ├── net40-full
│   │       │   └── log4net.dll
│   │       └── net45-full
│   │           └── log4net.dll
│   ├── MSBuild.ILMerge.Task.1.0.5
│   │   └── tools
│   │       └── MSBuild.ILMerge.Task.dll
│   ├── Newtonsoft.Json.12.0.2
│   │   └── lib
│   │       ├── net20
│   │       │   └── Newtonsoft.Json.dll
│   │       ├── net35
│   │       │   └── Newtonsoft.Json.dll
│   │       ├── net40
│   │       │   └── Newtonsoft.Json.dll
│   │       ├── net45
│   │       │   └── Newtonsoft.Json.dll
│   │       ├── netstandard1.0
│   │       │   └── Newtonsoft.Json.dll
│   │       ├── netstandard1.3
│   │       │   └── Newtonsoft.Json.dll
│   │       ├── netstandard2.0
│   │       │   └── Newtonsoft.Json.dll
│   │       ├── portable-net40+sl5+win8+wp8+wpa81
│   │       │   └── Newtonsoft.Json.dll
│   │       └── portable-net45+win8+wp8+wpa81
│   │           └── Newtonsoft.Json.dll
│   └── Newtonsoft.Json.8.0.3
│       └── lib
│           ├── net20
│           │   └── Newtonsoft.Json.dll
│           ├── net35
│           │   └── Newtonsoft.Json.dll
│           ├── net40
│           │   └── Newtonsoft.Json.dll
│           ├── net45
│           │   └── Newtonsoft.Json.dll
│           ├── portable-net40+sl5+wp80+win8+wpa81
│           │   └── Newtonsoft.Json.dll
│           └── portable-net45+wp80+win8+wpa81+dnxcore50
│               └── Newtonsoft.Json.dll
└── TestClients
    ├── MtApi5TestClient
    │   ├── bin
    │   │   └── Release
    │   │       ├── MtApi5.dll
    │   │       ├── MTApiService.dll
    │   │       └── Newtonsoft.Json.dll
    │   └── obj
    │       └── x86
    │           └── Release
    │               └── TempPE
    │                   └── Properties.Resources.Designer.cs.dll
    ├── TestApiClientUI
    │   ├── bin
    │   │   ├── Debug
    │   │   │   ├── MtApi.dll
    │   │   │   ├── MTApiService.dll
    │   │   │   └── Newtonsoft.Json.dll
    │   │   └── Release
    │   │       ├── MtApi.dll
    │   │       ├── MTApiService.dll
    │   │       └── Newtonsoft.Json.dll
    │   └── obj
    │       └── x86
    │           └── Release
    │               └── TempPE
    │                   └── Properties.Resources.Designer.cs.dll
    └── TestMtApi
        └── TestMtApi
            ├── bin
            │   ├── Debug
            │   │   ├── MtApi.dll
            │   │   ├── MTApiService.dll
            │   │   └── Newtonsoft.Json.dll
            │   └── Release
            │       ├── MtApi.dll
            │       ├── MTApiService.dll
            │       └── Newtonsoft.Json.dll
            └── obj
                └── x86
                    └── Release
                        └── TempPE
                            └── My Project.Resources.Designer.vb.dll

84 directories, 69 files

The tree structure of all available *.exe' applications...

Click Me!
# tree --dirsfirst --prune -P *.exe ./
./
├── build
│   └── installers
│       ├── Debug
│       │   └── MtApi_Setup.exe
│       └── Release
│           ├── MtApi_Setup.exe
│           └── MtApi5_Setup_x86.exe
├── packages
│   └── ILMerge.2.13.0307
│       └── ILMerge.exe
├── TestClients
│   ├── MtApi5TestClient
│   │   ├── bin
│   │   │   └── Release
│   │   │       └── MtApi5TestClient.exe
│   │   └── obj
│   │       └── x86
│   │           └── Release
│   │               └── MtApi5TestClient.exe
│   ├── TestApiClientUI
│   │   ├── bin
│   │   │   ├── Debug
│   │   │   │   └── TestApiClientUI.exe
│   │   │   └── Release
│   │   │       └── TestApiClientUI.exe
│   │   └── obj
│   │       └── x86
│   │           ├── Debug
│   │           │   └── TestApiClientUI.exe
│   │           └── Release
│   │               └── TestApiClientUI.exe
│   └── TestMtApi
│       └── TestMtApi
│           ├── bin
│           │   ├── Debug
│           │   │   └── TestMtApi.exe
│           │   └── Release
│           │       └── TestMtApi.exe
│           └── obj
│               └── x86
│                   ├── Debug
│                   │   └── TestMtApi.exe
│                   └── Release
│                       └── TestMtApi.exe
└── vcredist
    ├── vc_redist.x64.exe
    └── vc_redist.x86.exe

31 directories, 16 files

@KptKuck
Copy link

KptKuck commented Nov 14, 2020

MtApi5_Setup_x86.exe are obsolete.
Actually releases of MT5 runs only on 64Bit Windows
https://www.mql5.com/en/forum/325529

@eabase
Copy link
Contributor Author

eabase commented Nov 14, 2020

MtApi5_Setup_x86.exe are obsolete.

That's great new. Finally get rid of that extra "crust". Now it will be clear what's 32 vs 64 bit without confusing installations. Which mean that perhaps the next installer would do both MT4 and MT5.

@KptKuck
Copy link

KptKuck commented Nov 15, 2020

Maybe there will be big changes soon anyway.
I recently had contact with the developers. The tester will be completely rewritten.
This has surely to do with the fact that the MQ MT5-Python-API has no functionality for the strategy tester yet.
This will be in the new tester.
But this is only my guess.

Maybe it makes sense to wait until then and then reorient the project.

@eabase
Copy link
Contributor Author

eabase commented Dec 11, 2020

FAQ item:

Taken from Telegram:

  • Q: What is the difference between the installer and the bootstrap?

    A: The installer setup all libraries of the MtApi project into the defined folders: Window system, Window GAC and in Program Files). Boostrap is a bundle that contains the installer and vc_redist package. vc_redist is the Microsoft Visual C++ redistributable packages, which are runtime components in support of Windows applications compiled with Microsoft Visual Studio.

The reason why I made bootstrap for MtApi, is that many users sent feedbacks that MtApi is not working after install. I investigated dependences of the dll's on their PC and found that many versions of Windows does not contains some libraries needed for working MtApi (specifically MTConnector.dll, MT5Connector.dll were not loaded to MT). Users have to install vc_redist package separately. So I decided to facilitate installation process for users and made setup file that install both components (MtApi and vc_redist) automatically.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants