Question

Qt (http://qt-project.org/) looks like a great cross-platform framework for developing applications, however I can't seem to find if it can be use to create libraries.

Can I use it to create a reusable piece of code that will be compiled to a Windows .dll, OSX and iOS .dylib and Android .jar file?

Was it helpful?

Solution

Usually, the only difference between an application and a shared library is a few option bits in the image file. So yes, you can certainly use Qt to write reusable software libraries.

Here are the caveats:

  1. If the libraries that you create expose C++ interfaces (as opposed to C interfaces), your users will need to use the same compiler version to build their code that links with your library. The C interfaces must be declared extern C.

  2. If the library that you use is linking dynamically against Qt, then your user is forced to use a binary-compatible version of Qt: that means that it must be compiled with the same compiler, and without binary-incompatible changes.

For use on non-package-managed platforms (like Windows), I'd link my library statically to both Qt and the Visual C++ runtime. For platforms with package managers (Linux, macports on OS X), I'd offer both a statically linked library as well as a platform-specific package (say RPMs for RHEL6, macports portfile, etc.) that then depends on platform-standard C++ runtime, and Qt if such exists (some platforms don't provide Qt 5 yet).

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top