4

I downloaded qt recently.

I want to create an standalone exe, but I don't know what can I do.

In Qt5.2, the folder "(Qt)\lib" is exists, but i can't use it in Qt Creator.

So, should I build from source, or configure Qt Creator and use the "lib***.a"?

Any ideas?

Environment: MinGW-32 4.8.1(TDM) / Windows 7

László Papp
  • 51,870
  • 39
  • 111
  • 135
Tatsuyuki Ishi
  • 3,883
  • 3
  • 29
  • 41
  • "the folder "(Qt)\lib" is exists, but i can't use it in Qt Creator." -> what do you mean by that? What issue exactly are you facing? Also, what do you mean by this "should I build from source"? What would you like to build from source, Qt? – László Papp Jan 07 '14 at 06:22
  • The [licensing of Qt](http://qt-project.org/products/licensing) may prohibit or discourage static linking (at least for distributed software). See also [this answer](http://stackoverflow.com/a/10179181/841108) and read more about [LGPL](http://en.wikipedia.org/wiki/GNU_Lesser_General_Public_License); so you should not loose your time trying that (and link your program dynamically to Qt). – Basile Starynkevitch Jan 07 '14 at 06:23
  • @BasileStarynkevitch: license consideration applies for any software. This is a programming site after all, not general licensing. :-) – László Papp Jan 07 '14 at 06:27
  • @LaszloPapp Sorry for bad english. I searched for manything, and setted CONFIG+=static, but it always requires QtCore.dll. I need a exe without QtCore.dll(linked with libQtCore.a). – Tatsuyuki Ishi Jan 07 '14 at 06:43
  • 1
    @IshiTatsuyuki To expand on Basile's comment, note that the user (that is, whoever gets your statically linked .exe) must be able to change the LGPL part, which means the Qt libraries. For practical purposes, this means you must be ready to give your source code (license does not really matter much) to whoever gets the statically linked .exe, so they can re-build it with modified (newer version, bug-fixed, whatever) LGPL Qt. Disclaimer: IANAL – hyde Jan 07 '14 at 07:16
  • @hyde: the user could also be given a bunch of object files and the instructions to relink his modified `libQt*.a` with them. – Basile Starynkevitch Jan 07 '14 at 09:35

1 Answers1

5

You seem to have tried CONFIG+=static, but that is not meant for this use case. That is used when you would like to use build your library to be static after the end of the build.

This is not the case here because you already have static Qt libraries available, so what you wish instead, to link those statically against your executable.

You would need to use this in your qmake project file:

LIBS += -L/path/to/the/static/QtCore -lQtCore

You could also use, albeit this would make the build-system less portable across different platforms:

LIBS += /path/to/the/statis/QtCore/libQtCore.a
László Papp
  • 51,870
  • 39
  • 111
  • 135
  • I tried add it to pro file, but the file is still 48KB and don't links QtCore. Qt creator looks like know the lib directory. I just want to make Qt creator use these libraries. – Tatsuyuki Ishi Jan 07 '14 at 07:05
  • @IshiTatsuyuki: you are probably doing something wrong you have not shared with us. This oughta work... Provide more context... – László Papp Jan 07 '14 at 07:06
  • I added qmake arguments"CONFIG+=static". Using "Rebuild all", but it seems to not link any library(I added zlib). I added "win32:" before LIB+=. Is it wrong? – Tatsuyuki Ishi Jan 07 '14 at 07:15
  • @IshiTatsuyuki: have you read the post in its entirity? It explicitly writes you should _not_ use `CONFIG+=static`. – László Papp Jan 07 '14 at 07:20
  • Nothing changes...Still 48KB and requires Qt5Core/Qt5Cored.dll. – Tatsuyuki Ishi Jan 07 '14 at 07:28