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.

Community
  • 1
  • 1
iamnp
  • 500
  • 8
  • 22
  • 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 '13 at 11:24
  • Isn't that just an optimization flag? – lpapp Dec 22 '13 at 11:30
  • I don't know. Which one? – iamnp Dec 22 '13 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 '13 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? :) – lpapp Dec 22 '13 at 11:52
  • @iamnp: did you find my answer helpful or there is still something you are missing? – lpapp Dec 23 '13 at 03:47
  • Is this resolved now? – lpapp May 24 '14 at 06:06
  • Is it still unresolved more than one year later?? – lpapp Dec 21 '14 at 10:37

1 Answers1

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.

lpapp
  • 48,739
  • 39
  • 106
  • 133