What is a platform independent qt addon?

  • Hello,

    I want to make a program which use plugins for hardware . All this hardware is serial port hardware and use QSerialport. In windows I do a DLL file and load this. Same with linux and .so files. However, I like to get a code that can be compiled without platform dependencies, a own dynamic library. Of course it must be compiled for different OS.

    Is there a solution?


  • There's no such thing as "platform-agnostic code" when it comes to using I/O. The best you can do is to isolate the platform-dependent code in your own classes (e.g. you can write your own library loader, serial port class, etc), and then your sole responsibility will be to maintain those classes for the platforms you want to support. I mean, do not expect to have serial ports, window managers, sound interfaces, etc in STL or the likes any time soon.

  • I want to go this way:

    And QSerial port is a HW abstraction layer that works very well (until you make some code for the lock files in linux).
    However it seems there is a QLibrary which may solve the part in the codeproject article? Some platform independent loadlibrary function?
    I do not know :(

  • Qt can already handle libraries and plugins in a platform independent way. They still need to be compile to match their platform (like the application itself), but your code would not need to change.

    See the help section on "How to create Qt Plugins" for details.

Log in to reply

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.