Important: Please read the Qt Code of Conduct -

dll created with qt5 used for mt5(metaquotes5) gives the error "unresolved import function call"

  • i'v created a dynamic dll using qt5 c++ library.
    if the dll's functions won't use the Qt specicify things like QString QList ...etc...
    and erything goes well.
    but when the dll's function refernece to some Qt "inner" things as i describe earily. and the mt5
    show the error "unresovled import function call",and the dll can not be loaded!

    simple codes will say clearly:
    for example : the dll has a function add:

    extern "C"{
    __declspec(dllexport) int __stdcall add(int a,int b){
          return a+b;        

    and the dll did well ,it can give the expected results; but if i add something Qt specify for example:

    #include <QString>
    extern "C"{
    __declspec(dllexport) int __stdcall add(int a,int b){
          QString my_test_str="no actual functional capability,just for testing";
          return a+b;        

    as you can see ,i add the QString;
    and the dll will not be loaded,and throw errors.
    so the question is: can the qt5 make a dll used for a C interface instead c++?
    if so what i should do?

  • What deserves to be mentioned : i can use any stl in the dll function without any error
    just like this:

    #include <vector>
    extern "C"{
    __declspec(dllexport) int __stdcall add(int a,int b){
         std::string string="my test string";
         std::vector<const char*> my_test_vector[3];
         my_test_vector.push_back("my test string");
          return a+b;        

    the dll also works.
    it's very strange. QString vs std::string, qtl vs stl....that's a little interesting!

  • Lifetime Qt Champion

    Hi and welcome to devnet,

    This article might give you the clues you need.

    Hope it helps

  • @SGaist
    thanks for your help;
    but it doesn't work. because the QLibray is aslo the Qt Specifiy.
    Using any Qt inner object will throw errors.

  • Lifetime Qt Champion

    Did you saw that __declspec has to change when you build the library and when someone wants to use it ?

  • @guzuomuse said in dll created with qt5 used for mt5(metaquotes5) gives the error "unresolved import function call":


    Your Lib is not loaded while using Qt specific keywords because your lib is depends on other Qt dlls, use dependency injector or something to check on what dll's your dll is dependent.

  • @SGaist

    hi,what does the "__declspec has to change" mean?
    maybe you say: the exported dll's function names changed?
    they haven't changed; keep the same name as i defined;

  • Lifetime Qt Champion

    See the Creating Shared Libraries chapter of Qt's documentation.

  • @TobbY
    the only additional dependency dll is Qt5Core.dll; and it has been loaded together with the dll when imported.

  • @SGaist

    mank thanks to you both;

    finally, i solved this problem. in fact it's very easy.
    @TobbY is absolutely right.
    just put the dependencies dlls(here the only one Qt5Core.dll) and my dll in the same dir.
    i code the absolute path in the mql5,but left the dependency dll on the mt5's library before. that's not right.
    i'm so stupid! so i should give trust on the qt. it's my fault

Log in to reply