Hello,
I would like to know how to use the QLibrary to read a DLL library and call its functions.
I'll appreciate if someone could give me an example.
Thanks
Hello,
I would like to know how to use the QLibrary to read a DLL library and call its functions.
I'll appreciate if someone could give me an example.
Thanks
You don't use QLibrary to use a DLL in your application.
Just include the header file of the library, and link the library to your application.
Note that you can not use QLibrary to easily load C++ symbols. So, if your library is written in C++ and it doesn't extern C its symbols, you'll need a bit of work to get the correct symbols.
You cannot use QLibrary to scan a shared library to see what symbols it has. You need to get that list from the library's creator.
Once you know what's inside the library, you need to know the types of the symbols that you wish to access. These could be functions, classes or variables. In the case of functions, you need to know the function signature, in the case of classes, you need the class definition and in the case of variables, you need to have the data type. All these should be supplied by the creators in header files and/or DEF files.
Once you've decided what you need, you can load the library into memory using QLibrary (see Assistant) and then find the symbol's address using QLibrary::resolve(), converting the void* to the data type that the symbol represents.
how about if I use the function LoadLibrary? is that supported by QT?
Added after 11 minutes:
Thanks for the reply Robbie.
I already know what is inside the library. I'm talking about the mpusbapi.dll from microchip, I already have all the headers and sources code but specific to the boorland c++ builder compiler, so from there I can get the list of the function that I want to use.
How can I proceed from here? I need to make a DEF file?
Last edited by digog; 3rd November 2010 at 15:09.
I guess there's something fundamental you do not understand.I already have all the headers
You have the DLL, that's ok.
You have the headers (.h file) that's great.
Now, include the header file in your own source code and link the dll with your program.
Something in the lines of LIBS += -lmpusbapi should be added to your .pro file
I think what he really lacks is the import library but as far as I know this can be regenerated from the dll.
Thats ok.
The .h file is specific to the borland c++ compiler. I don't know if I can just include this .h file in my own project.You have the headers (.h file) that's great.
dont I need to have the .lib file for this? I have one here but, as I said before, its specific to the borland c++ compiler.link the dll with your program.
Something in the lines of LIBS += -lmpusbapi should be added to your .pro file
Sorry if I making a big confusion, its just all new for me.
The .h file holds the function prototypes which you will need with QLibrary too. So this is a problem you will have to resolve either way.
http://jrfonseca.planetaclix.pt/proj...imp/index.htmldont I need to have the .lib file for this? I have one here but, as I said before, its specific to the borland c++ compiler.
I'm sure there is an equivalent for Turbo C++.
What should I do with it?http://jrfonseca.planetaclix.pt/proj...imp/index.html
I'm sure there is an equivalent for Turbo C++.
Bookmarks