How to include a interface of a .dll file
-
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. -
If you want to load the dll dynamiclly you should have a look at QLibrary.
-
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();
}
@
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(*)()' -
"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 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.