1

I want to make a standalone .exe file in Qt msvc 2010 5. I change the mode to "release" and build my project and I copy the .exe file in release/debug folder to bin directory in Qt directory and then I copy all the bin folder. it works properly in my computer, but when I move the bin folder to other computers the .exe file doesn't work. I installed visual c++ 2010 redistributable package in the other computer but still it doesn't work. what should I do?

Aidin.T
  • 731
  • 3
  • 10
  • 25

1 Answers1

3

The answer is most likely that the other machine doesn't have Qt installed. If you want a wholly standalone Qt app on Windows (statically linked), check this out: http://qt-project.org/wiki/Build_Standalone_Qt_Application_for_Windows

Some quick build instructions -

  1. Make sure you have python installed and in your path Get the Qt source code (http://download.qt-project.org/official_releases/qt/5.1/5.1.1/single/qt-everywhere-opensource-src-5.1.1.zip)
  2. unzip the zip file and open a Visual Studio command prompt in that directory
  3. execute configure -static -release -no-audio-backend -opengl desktop -opensource -confirm-license
  4. execute nmake (this will compile all of Qt and will take a while depending on your processing power)
  5. add CONFIG+=static to your .pro file call qmake from the build of qt you just made and then run nmake on your project. You'll then get a statically linked binary. You'll know because even a very small program will be > 5MB in size.
ksimons
  • 3,797
  • 17
  • 17
  • for microsft msvc I have to use "configure" command, it's not a recognized command in visual studio command prompt. what is the problem? – Aidin.T Sep 29 '13 at 12:13
  • 1
    The configure command is in the root of the Qt source tree. As the article explains "The first step is to build a static version of Qt". Qt itself is not normally built for static linking, so to achieve what you're attempting, you'll need to build Qt yourself first. – ksimons Sep 29 '13 at 12:20
  • The other option is of course to distribute all of Qt along with your application. – ksimons Sep 29 '13 at 12:31
  • I didn't get it. how can I build Qt myself? – Aidin.T Sep 29 '13 at 12:32
  • The source code is available through git or as a download here: http://qt-project.org/downloads – ksimons Sep 29 '13 at 12:36
  • my other question is how can I build it?(sorry i'm a noob) – Aidin.T Sep 29 '13 at 12:38
  • Which version of Qt are you using currently? – ksimons Sep 29 '13 at 12:53
  • I just executed configure. but nmake results NMAKE : fatal error 1064: MAKEFILE not found and no target specified Stop. – Aidin.T Oct 03 '13 at 00:36
  • the last problem solved. please answer this question: [question](http://stackoverflow.com/questions/19149349/using-nmake-to-build-a-static-version-qt) – Aidin.T Oct 03 '13 at 01:19
  • I built Qt, but there is no qmake in the directory. what is the problem? – Aidin.T Oct 03 '13 at 17:07
  • 1
    It's in the qtbase\bin directory – ksimons Oct 04 '13 at 05:55