I am trying to understand the workflow for building DLLs for MQL to use external Cpp structures, functions and classes in Mql5 code.
A DLL FOR MQL5 IN 10 MINUTES (PART II): CREATING WITH VISUAL STUDIO 2017
When I set up a new DLL project (with exports) in VS2017, the project does not import “stdafx.h” or use the ‘extern “C” ‘ convention.
The article suggests I have to update the Visual Studio template to have 'extern "C"'. When I add 'extern "C"' to the code, I get a bunch of build errors. I noticed the project does not incude "stdfx.h"
If I do not add 'extern "C"', I am able to build the DLL in Visual Studio. But when I try to use it in MT5, I receive the typical error:
You'll notice I tried to change the path to the DLL library since I did not save it in the root "Libraries" folder. Neither way worked.
Is the issue around using extern c and stdafx.h or what do I need to do differently to get the library to work in MT5? The only headers that are imported into the DLL project in Visual Studio when starting a new DLL project 'with Exports' are
"pch.h"
"framework.h"
The Visual Studio DLL project With Exports files are pretty much the same between Visual Studio 2017 and Visual Studio 2022 (installed/updated as of today) and I would prefer to use Visual Studio 2022. So I think some things have changed. Either I need to find and include "stdafx.h" and add #pragma once and the other headers from the article. Or I'm missing something in my existing DLL code that would allow it to work in MQL5. Let me know if you need me to attach any files.
Can anyone with DLL building experience please provide some guidance?
I was able to get this working by changing the build to Release x64. I think it has more to do with the x64 part, than release? I'm not sure. Would still like clarification on that if possible. Also, I still want to understand what needs to be included for the DLL to work, vs what doesn't. Please leave a reply! Thanks!

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
I am trying to understand the workflow for building DLLs for MQL to use external Cpp structures, functions and classes in Mql5 code.
HOW TO EXCHANGE DATA: A DLL FOR MQL5 IN 10 MINUTES
A DLL FOR MQL5 IN 10 MINUTES (PART II): CREATING WITH VISUAL STUDIO 2017
When I set up a new DLL project (with exports) in VS2017, the project does not import “stdafx.h” or use the ‘extern “C” ‘ convention.
The article suggests I have to update the Visual Studio template to have 'extern "C"'. When I add 'extern "C"' to the code, I get a bunch of build errors. I noticed the project does not incude "stdfx.h"
If I do not add 'extern "C"', I am able to build the DLL in Visual Studio. But when I try to use it in MT5, I receive the typical error:
You'll notice I tried to change the path to the DLL library since I did not save it in the root "Libraries" folder. Neither way worked.
Is the issue around using extern c and stdafx.h or what do I need to do differently to get the library to work in MT5? The only headers that are imported into the DLL project in Visual Studio when starting a new DLL project 'with Exports' are
"pch.h"
"framework.h"
The Visual Studio DLL project With Exports files are pretty much the same between Visual Studio 2017 and Visual Studio 2022 (installed/updated as of today) and I would prefer to use Visual Studio 2022. So I think some things have changed. Either I need to find and include "stdafx.h" and add #pragma once and the other headers from the article. Or I'm missing something in my existing DLL code that would allow it to work in MQL5. Let me know if you need me to attach any files.
Can anyone with DLL building experience please provide some guidance?