Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. 3rd Party Software
  4. dll created with qt5 used for mt5(metaquotes5) gives the error "unresolved import function call"
QtWS25 Last Chance

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

Scheduled Pinned Locked Moved Solved 3rd Party Software
10 Posts 3 Posters 2.3k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • guzuomuseG Offline
    guzuomuseG Offline
    guzuomuse
    wrote on last edited by guzuomuse
    #1

    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?
    thanks

    guzuomuseG 1 Reply Last reply
    0
    • guzuomuseG guzuomuse

      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?
      thanks

      guzuomuseG Offline
      guzuomuseG Offline
      guzuomuse
      wrote on last edited by guzuomuse
      #2

      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!

      1 Reply Last reply
      0
      • SGaistS Offline
        SGaistS Offline
        SGaist
        Lifetime Qt Champion
        wrote on last edited by
        #3

        Hi and welcome to devnet,

        This article might give you the clues you need.

        Hope it helps

        Interested in AI ? www.idiap.ch
        Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

        guzuomuseG 1 Reply Last reply
        1
        • SGaistS SGaist

          Hi and welcome to devnet,

          This article might give you the clues you need.

          Hope it helps

          guzuomuseG Offline
          guzuomuseG Offline
          guzuomuse
          wrote on last edited by
          #4

          @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.

          1 Reply Last reply
          0
          • SGaistS Offline
            SGaistS Offline
            SGaist
            Lifetime Qt Champion
            wrote on last edited by
            #5

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

            Interested in AI ? www.idiap.ch
            Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

            guzuomuseG 1 Reply Last reply
            0
            • T Offline
              T Offline
              TobbY
              wrote on last edited by
              #6

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

              mt5

              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.

              guzuomuseG 1 Reply Last reply
              0
              • SGaistS SGaist

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

                guzuomuseG Offline
                guzuomuseG Offline
                guzuomuse
                wrote on last edited by
                #7

                @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;

                1 Reply Last reply
                0
                • SGaistS Offline
                  SGaistS Offline
                  SGaist
                  Lifetime Qt Champion
                  wrote on last edited by
                  #8

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

                  Interested in AI ? www.idiap.ch
                  Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                  1 Reply Last reply
                  1
                  • T TobbY

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

                    mt5

                    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.

                    guzuomuseG Offline
                    guzuomuseG Offline
                    guzuomuse
                    wrote on last edited by
                    #9

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

                    guzuomuseG 1 Reply Last reply
                    0
                    • guzuomuseG guzuomuse

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

                      guzuomuseG Offline
                      guzuomuseG Offline
                      guzuomuse
                      wrote on last edited by guzuomuse
                      #10

                      @SGaist
                      @TobbY

                      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

                      1 Reply Last reply
                      0

                      • Login

                      • Login or register to search.
                      • First post
                        Last post
                      0
                      • Categories
                      • Recent
                      • Tags
                      • Popular
                      • Users
                      • Groups
                      • Search
                      • Get Qt Extensions
                      • Unsolved