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

QMAKE: how to protect some *.o files from being erased during clean/distclean?



  • I am using QMAKE, and I have a 3rd party *.o file which I don't want to lose during "clean" and "distclean". How do I protect this file?

    The ultimate goal is to build a static *.a library out of that file and a few additional object files (which I don't mind losing).

    On Unix, I do this by changing QMAKE_AR_CMD which is UNIX-specific. On Windows, this doesn't work.

    I would love to have a cross-platform solution for this.

    Any help?


  • Lifetime Qt Champion

    Hi and welcome to devnet,

    Where does these file come from ? Are you building that 3party library ?



  • Hi SGaist,

    Thanks for welcoming me - The *.o file was given to me by the 3rd party library vendor. I don't have the source code for this library, so this object file is all I have. I obviously wouldn't want that file deleted during cleanup.

    I have a few additional object files, but those come from my own code. These other *.o files should be cleaned up, but not the 3rd party one.

    Many thanks.



  • So what you need is a custom link stage under the project file; something that references the external object .o files. I'd generally store them outside of the project folder tree, and create a project file that knows how to find them.

    see https://stackoverflow.com/questions/4644643/how-to-add-object-files-to-a-project-in-qt


Log in to reply