Monday, July 27, 2020

Installing and using Qt libraries with Conan

For some reason or the other, I always had Qt installed on my dev machine either by manually compiling it from sources or via apt-get. Recently I started using conan to install Qt libaries and qmake.
After installation however, I could not find an automated way of adding installed Qt binaries to my binary search path. Even after many searches online, I did not find any sample conanfile.txt anywhere showcasing the proper way to install Qt with conan. After going through conan documentation however, I found out that conan generator virtualrunenv can be used to tackle this problem. virtualrunenv generator can be used to add/remove directories installed by conan to your binary search path.
To add Qt binaries installed by conan to your PATH, execute:
source activate_run.sh
To remove them from the search path, execute:
source deactivate_run.sh
By adding virtualrunenv as one of your code generators, you can easily bring/remove qt binaries to/from your search path.
Below is my conanfile.txt which I use to install latest Qt 5.15.x via conan:
[requires]
qt/[>=5.15.0 <5.16.0]@bincrafters/stable

[generators]
qmake
virtualrunenv

Some of the disadvantages of using Conan to install Qt:

  • Qt installed via conan does not include Qt designer and other binaries. It only includes qmake.
  • Qt installation via Conan still requires few packages to be manually installed via APT.

More info:

1 comment:

Haowei Hsu said...

Actually, if we add `qt:qttools=True` option in `conan install` command or in `conanfile.txt`, it will include Qt Designer and other binaries. I've already tried and it worked.