0

I would like to compile staticly my Qt 5 application. I used this link : Qt static linking and deployment

The problem is that I don't know where is the "configure" file or how to generate it ?

ps: the old option to add "CONFIG = static" in the .pro file doesn't work with Qt5

Community
  • 1
  • 1
John Smith
  • 771
  • 4
  • 11
  • 25

2 Answers2

1

You have to first compile the whole Qt library statically. Then, use that configuration in your projects. Then, your application will be statically compiled.

Qt (when using qmake) takes the compilation configuration from its qmakespec, which is defined during compilation of the Qt library. This includes all the parameters that are used by default.

Keep in mind that this has a learning curve. You have to try and fail a few times. It'll cost you some time to get this right. That link I provided should make this effort easier.

Community
  • 1
  • 1
The Quantum Physicist
  • 24,987
  • 19
  • 103
  • 189
0

The problem is that I don't know where is the "configure" file or how to generate it ?

QMake make use of several type of files:

  • .pro
  • .pri
  • .prf

The most common is the .pro used for pro-jects. You can find/create it at the root of your project directory.

Creating a QtCreator project will automatically generate one. Be aware that there is also the qbs alternative.

the old option to add "CONFIG = static" in the .pro file doesn't work with Qt5

CONFIG *= static still works, are you sure about any other issue somewhere else?

CONFIG = static will override any previous value, using the * will append the new value without deleting previous configurations. I suggest you to use 'message( $$CONFIG)' to ensure the content is correct.

Adrian Maire
  • 14,354
  • 9
  • 45
  • 85
  • Adding `static` to config will not link Qt libraries statically to your program. Probably only the runtime library of the compiler, at best. It might even cause conflicts in the case of msvc compiler. – The Quantum Physicist May 03 '17 at 09:15
  • @TheQuantumPhysicist: of course, this only tell your code to be **compiled** as static library, not to link to it. It works fine with MSVC too (tested up to 2015) – Adrian Maire May 03 '17 at 09:16