Important: Please read the Qt Code of Conduct -

How to generate .pro.user from command line?

  • I have a .pro file, and I want to generate an accompanying .pro.user file, without using qtcreator. Is there a way to generate the .pro.user file using 'qmake'? qmake with no options generates a Makfile from the .pro file, but the generated Makefile doesn't contain the 'moc' commands to build the moc_* files. I haven't been able to find a qmake option that will do this...


  • Lifetime Qt Champion


    No, that file is Qt Creator specific an contains only information that pertains to Qt Creator.

    It has nothing to do with generating moc files.

    What is your exact issue ?

  • @SGaist - I want to build a Qt project using only command line tools, without the need to use qtcreator. This is proving to be a real struggle for me. First I developed my app with qtcreator and qmake - it builds fine. Now to test building without qtcreator I've copied my .cpp, .h, .qml, qml.qrc and .pro files to a separate directory. In that directory I type 'qmake' to generate a Makefile, but the project does not properly build. Comparing the Makefiles generated in the original (qtcreator) directory and the test (qmake-only) directory, there are many differences. In particular the original Makefile includes '-I /usr/local/include' in its compilation flags, but the test directory Makefile does not - one reason why building in the test directory fails.
    I assume I have not copied some file needed by qmake to build a working Makefile, but what?

  • Lifetime Qt Champion

    Are you sure you are using the same qmake executable ?
    A recommandation is to always use the full path to the executable.

  • @SGaist - Yes, 'which qmake' shows I am using the same qmake in both cases.
    Looking for a clue, I opened qtcreator in the test directory, and get this error message:

    All settings files found in directory "/home/oreilly/projects/mb-system/MB-System/src/qttest/" were unsuitable for the current version of Qt Creator, for instance because they were written by an incompatible version of Qt Creator, or because a different settings path was used.

    So, why does qtcreator give this warning? I don't understand how it "knows" a different settings path was used. I am thinking this is one cause of my problem...

  • Lifetime Qt Champion

    What errors are you getting ?

  • @SGaist - The Makefile generated by qmake in the test directory does not include /usr/local/include in its compilation flags, whereas the qmake-generated Makefile in the original directory does. So the compiler cannot find headers in /usr/local/include.

  • Lifetime Qt Champion

    That's typically a folder that you should add to the INCLUDEPATH variable in your .pro file.

  • @SGaist - Thanks! How do I specify that "system" include directory in a platform-neutral way in the .pro file?

  • Lifetime Qt Champion

  • @jsulm - I see, thank you @jsulm and @SGaist !

Log in to reply