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. How to include a interface of a .dll file
Forum Updated to NodeBB v4.3 + New Features

How to include a interface of a .dll file

Scheduled Pinned Locked Moved General and Desktop
7 Posts 3 Posters 4.0k 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.
  • S Offline
    S Offline
    Subhash
    wrote on last edited by
    #1

    Hi,
    I am new to this forum,I am able to include a dll library in my program but i dont know how to create a object of a interface present in the dll file.
    I would like to call a interface called ICamera2Ptr which is present in Apogee.dll.

    Can anyone help to do it?
    If code is needed we will post it.

    1 Reply Last reply
    0
    • G Offline
      G Offline
      goetz
      wrote on last edited by
      #2

      You will need the header files of the library, usually located in a directory named "include". Add the directory to the include path of your project like this:

      @
      INCLUDEPATH += /path/to/your/lib/include
      @

      http://www.catb.org/~esr/faqs/smart-questions.html

      1 Reply Last reply
      0
      • S Offline
        S Offline
        sven.bergner
        wrote on last edited by
        #3

        If you want to load the dll dynamiclly you should have a look at QLibrary.

        Coding less and creating more with every new version of Qt a bit more.

        1 Reply Last reply
        0
        • S Offline
          S Offline
          Subhash
          wrote on last edited by
          #4

          hi,
          thanks for the reply we r appending our code so far
          @#include <QtCore/QCoreApplication>
          #include<stdio.h>
          #include<QLibrary.h>
          int main(int argc, char *argv[])
          {
          QCoreApplication a(argc, argv);
          QLibrary asd("C:/subh/Apogee");
          typedef void (*ICamera2Ptr)();

          ICamera2Ptr d;
          bool ab,c;
          ab=asd.load();
          if(asd.isLoaded()==true)
          
          {
              printf("Loaded properly");
              c=d.ShowDialog(true);
          
          }
          else
          {
              printf("not loaded");
          }
          return a.exec&#40;&#41;;
          

          }
          @
          but we are able to include the dll in our program but when we try to implement any of the member functions in it v are getting an error..
          request to member-function"ShowDialog" in 'd',which is a non-class type 'void(*)()'

          1 Reply Last reply
          0
          • G Offline
            G Offline
            goetz
            wrote on last edited by
            #5

            "QLibrary docs":http://doc.qt.nokia.com/4.7/qlibrary.html has the answer:

            The symbol must be exported as a C function from the library...

            The most important functions are load() to dynamically load the library file, isLoaded() to check whether loading was successful, and resolve() to resolve a symbol in the library

            Your symbol seems to be a C++ one, and you did not call resolve() (which would fail, as it searches for C symbols).

            From what I see it seems to be a problem that is not solved by using QLibrary but by linking to the DLL/lib at compile time (and using the correct header files).

            http://www.catb.org/~esr/faqs/smart-questions.html

            1 Reply Last reply
            0
            • S Offline
              S Offline
              Subhash
              wrote on last edited by
              #6

              [quote author="Volker" date="1298044820"]"QLibrary docs":http://doc.qt.nokia.com/4.7/qlibrary.html has the answer:

              The symbol must be exported as a C function from the library...

              The most important functions are load() to dynamically load the library file, isLoaded() to check whether loading was successful, and resolve() to resolve a symbol in the library

              Your symbol seems to be a C++ one, and you did not call resolve() (which would fail, as it searches for C symbols).

              From what I see it seems to be a problem that is not solved by using QLibrary but by linking to the DLL/lib at compile time (and using the correct header files).
              [/quote]

              I am Sorry but can u explain how to export it as C symbol and how to solve this error..Please help me.

              1 Reply Last reply
              0
              • G Offline
                G Offline
                goetz
                wrote on last edited by
                #7

                RTFM. The link is in my first comment.

                http://www.catb.org/~esr/faqs/smart-questions.html

                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