Building Qt: 'make clean' causes everything to get recompiled?

41,630

Solution 1

I don't know where you got the idea that doing a make clean before a make install was somehow something you should be doing.

The canonical INSTALL file for autotools spells out the process:

  1. ./configure
  2. make
  3. make check (optional)
  4. make install
  5. make installcheck (optional)

At item 6, it says:

You can remove the program binaries and object files from the source code directory by typing make clean.

(Emphasis mine.)

make clean is something you do before recompiling, to make sure you get a clean build and don't have left-over by-products from previous runs. You can do it after a make install if you want to free some space but keep the source and configuration around. You should not do it before installing.

Solution 2

Qt build script works like this:

1 First build qmake
2 Generate Makefile for a subprojects (*.pro)
3 Start building libaries, then examples and demo projects

Yes, make clean will clean everything but your config file generated by Qt.

My trick is remove the "demo" and "examples" in the top *.pro file, which save about 40% time (on a i5 CPU)

Anway, you could setup ccache to speed up compiling, but that requires about 2G+ disk space for buffering

Share:
41,630

Related videos on Youtube

syntaxerror
Author by

syntaxerror

Shyy erny anzr - Naqernf Rvonpu

Updated on September 18, 2022

Comments

  • syntaxerror
    syntaxerror over 1 year

    (This applies to Qt versions >= 4.7.3.) I made an attempt to build Qt with custom parameters on my Debian box and it actually took AGES to compile (IIRC more than 6 hours on a single-core CPU). That's why I wanted to make sure I won't make any stupid mistakes in the process. However, I chose to do a make clean to get the *.o files and other stuff cleaned up after successful linking. It seemed a bad idea! For I did a make install just after that, and you won't believe it, the make clean attempt caused everything to get recompiled after the cleanup process! Though up to now, I've been thinking that make clean does allow a neat installation even with all object files and related stuff removed. Obviously, with Qt, things are different.

    In the official documentation for Qt 4.7 (cf. http://qt-project.org/doc/qt-4.7/install-x11.html), they did not even mention an optional make clean in the sequence of commands. As I know now, for a good reason. All the same, I can't call this "complying with standards" as I've already compiled hundreds of open-source apps, and NEVER did make clean trigger any recompilation process nor remove anything that should be kept (unless there was a bug in there)

    • Amitav Pajni
      Amitav Pajni over 11 years
      In any sane system, make clean cleans up the build directory. Of course everything would get compiled again. I don't know what you've been working with that make clean wouldn't have this effect, but it doesn't sound particularly sane.
  • syntaxerror
    syntaxerror over 11 years
    Yeah, you're right: that demos/examples stuff is indeed a very huge part of the story. Saved me lots of time indeed. I knew that already, but thanks for pointing it out anyway. :)
  • syntaxerror
    syntaxerror over 11 years
    Well, I think my main problem was that I thought what you were trying to explain was "already" a make distcleanand not make clean. I had assumed make clean to be a lot less "drastic". :) Obviously I was wrong.