Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Load dll Library
Forum Updated to NodeBB v4.3 + New Features

Load dll Library

Scheduled Pinned Locked Moved Unsolved General and Desktop
6 Posts 4 Posters 647 Views 1 Watching
  • 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.
  • A Offline
    A Offline
    aminemaar
    wrote on last edited by
    #1

    Hello after building a DLL library with visual studio, I linked the DLL in my QT project but it not working

    this my code

    QLibrary myLib("DLLSUM.dll");
        myLib.load();
        typedef int(*FNPTR)(int a, int b);
        
        FNPTR pSum = (FNPTR) myLib.resolve("sum");
    
        if (pSum)
            qDebug() << "sum = " << pSum(5,2);
        else
            qDebug("DLLSUM not Loaded");
    
    JonBJ 1 Reply Last reply
    0
    • A aminemaar

      Hello after building a DLL library with visual studio, I linked the DLL in my QT project but it not working

      this my code

      QLibrary myLib("DLLSUM.dll");
          myLib.load();
          typedef int(*FNPTR)(int a, int b);
          
          FNPTR pSum = (FNPTR) myLib.resolve("sum");
      
          if (pSum)
              qDebug() << "sum = " << pSum(5,2);
          else
              qDebug("DLLSUM not Loaded");
      
      JonBJ Offline
      JonBJ Offline
      JonB
      wrote on last edited by
      #2

      @aminemaar
      And would you care to tell us what your qDebug() output...?

      A 1 Reply Last reply
      3
      • JonBJ JonB

        @aminemaar
        And would you care to tell us what your qDebug() output...?

        A Offline
        A Offline
        aminemaar
        wrote on last edited by
        #3

        @JonB qDebug() return this message "DLLSUM not Loaded"

        jsulmJ 1 Reply Last reply
        0
        • mrjjM Offline
          mrjjM Offline
          mrjj
          Lifetime Qt Champion
          wrote on last edited by
          #4

          Hi
          Could you try

           if (!myLib.load())
                  qDebug() << myLib.errorString();
          

          and see what it says ?

          1 Reply Last reply
          4
          • A aminemaar

            @JonB qDebug() return this message "DLLSUM not Loaded"

            jsulmJ Offline
            jsulmJ Offline
            jsulm
            Lifetime Qt Champion
            wrote on last edited by
            #5

            @aminemaar Why don't you simply link against this lib instead of loading it dynamically?
            Also, you're using a relative path, depending on the current working directory QLibrary will simply not find the lib.

            https://forum.qt.io/topic/113070/qt-code-of-conduct

            1 Reply Last reply
            4
            • A Offline
              A Offline
              aminemaar
              wrote on last edited by
              #6

              @mrjj thank's I knew the problem with

              myLib.errorString();
              

              @jsulm thank's the path was incorrect

              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