Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

Qt and pkg-config



  • Hi, ALL,

    Is it possible to have Qt and pkg-config work together?

    The task:

    I'm working on software that uses wxWidgets. wxWidgets mainly uses GTK+ which uses pkg-config. Unfortunately my task is requiring to have a native control. For GTK it is very simple - I just modified the include and library options by adding the appropriate pkg-config options.

    Now, what I'd like to do is to add the same pkg-config options if I am building with Qt back-end in order to be simple and maintainable, because adding Qt-specific thing is not a good idea - what if the user won't have Qt installed and have GTK only? Then the configure will fail and so the build.

    So now the question is - how do I add the pkg-config for Qt?

    I just need to find the appropriate headers and libraries to build.

    That way I will have on;y 1 makefile to keep and it will be unified.

    Everything for Qt-5.0+, please.

    Thank you.


  • Lifetime Qt Champion

    Hi,

    Run pkg-config --list-all to check if you have Qt Libraries installed there.

    Are you targeting your distribution provided Qt ?
    Are you using a manually written Makefile ?



  • @SGaist said in Qt and pkg-config:

    Hi,

    Run pkg-config --list-all to check if you have Qt Libraries installed there.

    Will check it tonight.
    Also, I do have them installed (and I ran KDE WM).

    However, running "pkg-config --cxxflags" gives an error.
    Unfortunately I'm at work and not in front of that machine.

    Are you targeting your distribution provided Qt ?

    Yes. Also, iot is possible to have 2 versions installed, right?

    Are you using a manually written Makefile ?

    No. My Makefile is generated by Anjuta IDE.


  • Lifetime Qt Champion

    I would recommend moving to a project management tool like cmake. It will allow you to more easily switch between different versions of a framework like Qt.



  • Hi,
    @SGaist said in Qt and pkg-config:

    I would recommend moving to a project management tool like cmake. It will allow you to more easily switch between different versions of a framework like Qt.

    I'm still doing development and testing.

    CMake is a good tool to create a distribution Makefile when everything is already done and ready to be shipped.

    I will update the thread with the info running pkg-config when I get home.

    Thank you.


  • Lifetime Qt Champion

    @oneeyeman1 said in Qt and pkg-config:

    CMake is a good tool to create a distribution Makefile when everything is already done and ready to be shipped.

    No no, it's a tool to use from the start to manage your project and its dependencies.



  • Hi,
    @SGaist said in Qt and pkg-config:

    @oneeyeman1 said in Qt and pkg-config:

    CMake is a good tool to create a distribution Makefile when everything is already done and ready to be shipped.

    No no, it's a tool to use from the start to manage your project and its dependencies.

    Then what is IDE for?
    It is not to just edit and debug the code, it is also a tool to generate the project and create an appropriate Makefile.

    Thank you.


  • Lifetime Qt Champion

    @oneeyeman1 said in Qt and pkg-config:

    It is not to just edit and debug the code, it is also a tool to generate the project and create an appropriate Makefile.

    No, in QtCreator this is done ether by qmake or cmake. QtCreator itself does not generate any makefiles. Why should it if there are already build tools like qmake/cmake? This also applies to most other IDEs, even Microsoft Visual Studio which uses MSBuild and also supports CMake.



  • Hi,
    @jsulm

    I don't know anything about QtCreator.
    All I know is that when I try to create a solution in MSVC it will crete a project and then I will set the appropriate include/lib options.

    Xcode is kind of the same way.

    In Anjuta I create a workspace, add the project(s) and it will generate the Makefile for the build, based on the appropriate template.

    Thank you.

    P.S.: Now, all I need is to ask the shell where the Qt headers/libraries are...


  • Lifetime Qt Champion

    Xcode as well as Visual Studio have concepts of higher level projects.

    It looks like Anjuta hasn't seen an update for quite some time with regard to modern project management system like cmake, qmake or the others that exists.

    You really should consider moving to a more modern IDE like Qt Creator, Kdevelop, or even Visual Studio Code.

    It would make your task simpler in the long run.



  • I've never known Qt to work with pkg-config, nor be compatible with it, since Qt uses its own Makefile gnerator.


  • Lifetime Qt Champion

    Qt has support for pkg-config both to use it to link to libraries as well as for the lib template. From the looks of it, on Debian, there are .pc files available for the various Qt modules.


Log in to reply