问题
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?
回答1:
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 -
- 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)
- unzip the zip file and open a Visual Studio command prompt in that directory
- execute
configure -static -release -no-audio-backend -opengl desktop -opensource -confirm-license - execute
nmake(this will compile all of Qt and will take a while depending on your processing power) - add CONFIG+=static to your .pro file call
qmakefrom the build of qt you just made and then runnmakeon your project. You'll then get a statically linked binary. You'll know because even a very small program will be > 5MB in size.
来源:https://stackoverflow.com/questions/19077599/standalone-exe-in-qt