1

Now Qt generates one .o file per every .cpp file in my project. Can I force it to generate only one huge .o file? Or can I convert multiple .o files in a single one using some utils?

Edit1: The reason why I am doing that is because I want to compile a signle exe (no dlls) but LGPL requires that statically linked programs must be provided with it's object files. Here (https://stackoverflow.com/a/17736670/1389883) written that I can provide only one huge object file.

8
  • Don't think that is possible. But maybe you could explain the reason for wanting to do that. Typically, packing objects together is done when creating a static library.
    – Pat
    Dec 22, 2013 at 11:24
  • Isn't that just an optimization flag? Dec 22, 2013 at 11:30
  • I don't know. Which one?
    – iamnp
    Dec 22, 2013 at 11:34
  • Maybe instead of making one huge obj file (it's not possibly without breaking your project structure), create one static library ? It's a archive that's contains obj files. I think static lib will satisfy LGPL requirements.
    – sim
    Dec 22, 2013 at 11:40
  • @ThijsvanDien: why would that be a duplicate? The OP does not seem to have mentioned gcc. What if it needs to be cross-platform or only working for clang and/or msvc? :) Dec 22, 2013 at 11:52

1 Answer 1

1

Your question is not clear which toolchain you are working with, so I will assume you need a cross-platform solution as opposed to one specific.

I think you are looking for something that we have used in the KDE which was KDE4_ENABLE_FINAL. It will decrease the linkage time by having one object file as you wish to have, but on the other hand, it will use more memory for sure.

You can check how that cmake variable is handled underneath. It basically just concatenates the source files together to be a single compilation unit. It is done because there is no such a direct option to the underlying toolchains.

2
  • is it option for gcc or ld? could you provide link?
    – sim
    Dec 22, 2013 at 11:47
  • @sim: no, it is not. It is a trick on top of the toolchains. Note that the OP did not mention gcc. Dec 22, 2013 at 11:48

Not the answer you're looking for? Browse other questions tagged or ask your own question.