John Smith
John Smith

Reputation: 861

How to compile staticly a Qt 5 application?

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

Upvotes: 0

Views: 1209

Answers (2)

The Quantum Physicist
The Quantum Physicist

Reputation: 26256

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.

Upvotes: 1

Adrian Maire
Adrian Maire

Reputation: 14815

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.

Upvotes: 0

Related Questions