PDA

View Full Version : linking to 3rd party windows DLL



shan
29th January 2011, 01:52
I want to move a desktop Windows app, which communicates with certain devices through a system USB port, from the Visual Studio development environment to the Qt environment. Qt makes the GUI interface very easy but accessing the USB port is not so simple. USB communication requires making calls to functions in a 3rd party DLL library (from FTDI, a USB chip maker). I found some discussion of this at StackOverflow (http://stackoverflow.com/questions/2590299/importing-dll-into-qt) but there was some disagreement about best methods.

1) Does Qt provide any documentation to support the programming and build? (i.e. importing function prototypes, linking to the library, ..)

2) Is there a better approach to USB communication in Qt?

ChrisW67
29th January 2011, 09:42
1) Does Qt provide any documentation to support the programming and build? (i.e. importing function prototypes, linking to the library, ..)

If you use Qmake to build your project then you want to adjust the INCLUDEPATH and LIBS entries (look in the Qmake docs). Search in this forum... the topic has been gone over several times. If you are using CMake or something else then Qt documentation will not help.

If the library exports C++ objects (mangled names) then you must match the compilers (i.e. almost mandates MSVC). If the library exports on C (plain) names then either MingW or MSVC will work.


2) Is there a better approach to USB communication in Qt?
No.

squidge
29th January 2011, 10:51
I want to move a desktop Windows app, which communicates with certain devices through a system USB port, from the Visual Studio development environment to the Qt environment. Qt makes the GUI interface very easy but accessing the USB port is not so simple. USB communication requires making calls to functions in a 3rd party DLL library (from FTDI, a USB chip maker).I use FTDI chips a lot and by far the easiest way to use them is to use the provided virtual serial port driver, and then you can talk to your device via Qextserialport and the like.

FTDI also supply full library files and include files should you not wish to do this, so its just a matter of calling functions in that library. No need for importing functions from DLLs. The provided code from FTDI does all that for you.