1

I have been working on a Qt project using MinGW with Qt Creator under Windows. The Qt is used as a shared library, thus DLLs are needed to be copy to the distribution folder. However, a couple of members in our teams required that to be a standalone executable and use MSVC as compiler. We have a Qt library that was built statically according to whoever built it.

I would love to use Qt Creator as before. As some people suggested, I addedCONFIG += static

into my .pro file. However, when I select the qmake.exe under bin folder of static Qt library in the build settings, it always complains Qt version not valid and not properly installed. I tried to override some environment variables, which don't help either.This method should just work according to various posts on the internet and on Qt's Wiki. I am not sure why it does not work in my case.

I also have tried to use qmake from command line. However, whenever I make the project it always looks to the valid Qt shared library that is local installed on my PC. And the result of this, is still a executable with the need to copy DLLs.

The only way by which I can get it to build is to use the method suggested here:Using Qt with Visual Studio without add-in. Basically it is to use qmake on .pro with template += vcapp set. Then use visual studio with the generated .vcproj file to build the project. I don't really like this approach, as even the generated .vcproj doesn't default the inclusion and lib path to the static Qt lib but the shared Qt. Every time I generate it, I have to change it. It seems only to work with Debug build as well.

I am wondering is there a simpler way to do build a standalone exe against a static Qt library, preferably using Qt Creator? Our visual studio is express version, so no Qt Add-in available.

Community
  • 1
  • 1
Scrathis
  • 79
  • 1
  • 10
  • 1
    First, you should build your Qt statically. Only then you could use it in your projects. Note, that there are difference between static Qt and static CRT. – Dmitry Sazonov Jan 31 '14 at 08:46
  • possible duplicate of [Qt static linking and deployment](http://stackoverflow.com/questions/1011197/qt-static-linking-and-deployment) – sashoalm Jan 31 '14 at 12:33
  • As I have mentioned, we have a qt statically built already. – Scrathis Jan 31 '14 at 13:39
  • I don't have other plugins used in the project ATM. – Scrathis Jan 31 '14 at 13:41
  • Checkout this [link](http://qtnbeyond.blogspot.de/2011/03/statically-building-with-qt-creator-in.html). I got lot of good points out there and finally managed to build static linked applications with Qt Creator. Good luck! – inspector Jan 31 '14 at 12:31
  • This leads me to the thoughts of qt not properly built statically in our repo. – Scrathis Jan 31 '14 at 13:44
  • Well, it works, but you need time and lot of coffee ;-) I have managed it finally, however, static Qt on Mac is still not working properly. – inspector Feb 04 '14 at 22:32
  • I would believe that it should work straight away with Qt Creator if I recompile Qt statically again. But I dont want there to be two versions of Qt in our repo. – Scrathis Feb 05 '14 at 16:29

0 Answers0