Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7407757
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T05:46:51+00:00 2026-05-29T05:46:51+00:00

This must be a basic question but I am struggling with this problem for

  • 0

This must be a basic question but I am struggling with this problem for too long now.
I’ve looked everywhere on Google and found some similar problems and solutions but none that solved my specific problem.

I’ve written a very basic C++ DLL. In fact it is almost in C style because the DLL only has a main.cpp code file with a function in it so it’s not even using a class.

Then I have two header files :

MqlUtils.h :

#ifndef MQLUTILS_H
#define MQLUTILS_H

struct MqlStr
{
    int len;
    char *string;
};

enum TradeOperation
{
    OP_BUY = 0,
    OP_SELL = 1,
    OP_BUYLIMIT = 2,
    OP_SELLLIMIT = 3,
    OP_BUYSTOP = 4,
    OP_SELLSTOP = 5
};

#endif

main.h :

#ifndef _DLL_H_
#define _DLL_H_

#include "MqlUtils.h"

#define MT4_EXPFUNC __declspec(dllexport)

#define export extern "C" __declspec( dllexport )

 MT4_EXPFUNC int __stdcall  GetOrdersDetailsNoSymbol(const int orderCount, const char * MasterLicense, const char * SlaveLicense, int orderTicket[], int op[],
    double orderOpenPrice[], double orderStoploss[],
    double orderTakeProfit[], double orderLots[], int orderDateTime[],
    MqlStr * ordersymbol, MqlStr * ordercomments, int lotsCopyingMethod[], int returnedOrders[]);

#endif /* _DLL_H_ */

In fact, for creating my DLL, I started with existing code that someone else wrote, so the .cpp file for my DLL has some obscure syntax that I am not even sure what it is doing. Here’s an excerpt of what the .cpp looks like :

#include "main.h"

#define _UNICODE 1
#define UNICODE 1
#define WIN32_LEAN_AND_MEAN

// ...

EXTERN_C IMAGE_DOS_HEADER __ImageBase;


#if BUILDING_DLL
#define DLLIMPORT __declspec (dllexport)
#else /* Not BUILDING_DLL */
#define DLLIMPORT __declspec (dllimport)
#endif /* Not BUILDING_DLL */

// ...

#ifdef __cplusplus
extern "C"
{
#endif

// ... function code

#ifdef __cplusplus
}
#endif

I did not include everything that is in the .cpp file, where there are // ... there is something else but it’s basic stuff that I understand well so it shouldn’t be the source of my problem…I’ll be glad to post more as needed.

I am not an expert with all the obscure keywords like __declspec and such, but the DLL as it is, can be succesfully imported and the function GetOrdersDetailsNoSymbol can be used by some program, namely MetaTrader 4 (which is the main goal of my lib).

But now I would like to be able to test my library with a C++ program, so I created an empty console program, added the library project to the testing project’s references and linked the .obj and .h files through the testing project’s properties.

I am currently getting this when I compile the testing project :

Error   2   error LNK1120: 1 unresolved externals   Z:\Codes\Debug\TestsCpp.exe TestsCpp
Error   1   error LNK2019: unresolved external symbol "__declspec(dllimport) int __cdecl GetOrdersDetailsNoSymbol(int,char *,char *,int * const,int * const,double * const,double * const,double * const,double * const,int * const,struct MqlStr *,struct MqlStr *,int * const,int * const)" (__imp_?GetOrdersDetailsNoSymbol@@YAHHPAD0QAH1QAN2221PAUMqlStr@@311@Z) referenced in function "void __cdecl TestClient(void)" (?TestClient@@YAXXZ)    Z:\Codes\TestsCpp\main.obj  TestsCpp

Oh and here’s the main.cpp for the testing project :

#include "MqlUtils.h"
#include "main.h"

extern __declspec(dllimport) int GetOrdersDetailsNoSymbol(int orderCount, char * MasterLicense, char * SlaveLicense, int orderTicket[], int op[],
    double orderOpenPrice[], double orderStoploss[],
    double orderTakeProfit[], double orderLots[], int orderDateTime[],
    MqlStr* ordersymbol, MqlStr* ordercomments, int lotsCopyingMethod[], int returnedOrders[]);


void TestClient()
{
   char* Master = "7C83C4C2";
   char* Slave = "3B7C22A";

   int returnedOrderCount[1] = {0};

   double aStoredOrderOpenPrice[4];
   int aStoredOrderType[4];
   int aStoredOrderTicket[4];
   double aStoredOrderStopLoss[4];
   double aStoredOrdeTakeProfit[4];
   double aStoredOrderLots[4];
   int aStoredOrderDateTime[4];
   int aStoredLotsMethods[4];
   MqlStr* aStoredOrderComment[4];
   MqlStr* aStoredOrderSymbol[4];

   for (int i = 0; i < 4; i++)
   {
      aStoredOrderOpenPrice[i]= -1;
      aStoredOrderType[i]= -1;
      aStoredOrderTicket[i]= -1;
      aStoredOrderStopLoss[i]= -1;
      aStoredOrdeTakeProfit[i]= -1;
      aStoredOrderLots[i]= -1;
      aStoredOrderDateTime[i]= -1;
      aStoredLotsMethods[i]= -1;

      aStoredOrderComment[i]->len = 56;
      aStoredOrderComment[i]->string = "11111111111111111111111111111111111111111111111111111111";
      aStoredOrderSymbol[i]->len = 56;
      aStoredOrderSymbol[i]->string = "11111111111111111111111111111111111111111111111111111111";
   }


   GetOrdersDetailsNoSymbol(1, Master, Slave, aStoredOrderTicket,  aStoredOrderType,
                                            aStoredOrderOpenPrice, aStoredOrderStopLoss,
                                            aStoredOrdeTakeProfit, aStoredOrderLots, aStoredOrderDateTime,
                                            *aStoredOrderSymbol, *aStoredOrderComment,     aStoredLotsMethods, returnedOrderCount);
}

int main(int argc, char **argv)
{
   TestClient();

   return 0;
}

If anyone could help me solve this, I would be infinitely grateful.

Thanks for reading!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-29T05:46:53+00:00Added an answer on May 29, 2026 at 5:46 am

    Your two declarations of GetOrdersDetailsNoSymbol do not match. In your header file you declare it with __stdcall and in main.cpp you don’t. You should have only a single declaration. It can use #define and #ifdef to apply the dllimport or dllexport keywords as appropriate.

    EDIT: Also, get rid of the extern “C” statements. And then use the DLLIMPORT #define to declare your function and only #define BUILDING_DLL in the build of your DLL.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I realise that this must be a very basic question, but my google-fu seems
Im sure this is so basic question but i can't found any solution on
This must be a very basic question for Java developers, but what is the
This question must be really basic, but if you have any pointers I would
this is a real basic question but i was struggling at it from 30
This seems very basic and I must be missing something, but here goes anyways...
Now I must be missing something here, as this seems a very basic issue
This must be a very simple question, but I don't seem to be able
This must be a stupid question, but nevertheless I find it curious: Say I
This must be a dumb question, but I don't see any obvious references. How

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.