Results 1 to 8 of 8

Thread: How to create finished executable?

  1. #1
    Join Date
    Aug 2011
    Posts
    5
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default How to create finished executable?

    I know this is a noob question and that it's been asked before, but I am still stuck and I've been trying to get this to work for the past 6 days, so I'm resorting to asking here.

    I'm relatively new to programming. I only know a little C++ and just started trying to learn Qt last week. I have a program (a stat point calculator for a game I play) that I wrote as a console application in C++ using Dev C++. That worked flawlessly. Then I installed QtSDK v1.1.2 with Qt Creator 2.2.1 and Qt libraries version 4.7.3, and I attempted to recreate it in a GUI form. This was also a success. When building and running it in Qt Creator, it looks and behaves as it should.

    What I can't figure out is how to make an executable or package that I can distribute to others (fellow players who would like to use it). I understand the basic idea that Qt defaults to dynamic linking, and I guess this creates a software package that can be installed? I'm not sure, because I haven't figured out how to do this.

    Ideally, I'd prefer a standalone executable for this program, which I'm also aware requires static linking. For the past 6 days I've tried uninstalling and reinstalling various version of Qt, mingw, Qt Creator, as well as the whole Qt SDK bundle, every combination of configure -static -release, mingw32-make, and other commands I got from tutorials, but nothing has worked. Everything I tried either isn't possible (because the tutorial was outdated and didn't apply to any versions I could get my hands on) or resulted in errors I couldn't figure out how to resolve.

    Apparently I'm not the only one with this problem.
    http://www.qtcentre.org/threads/4337...n-qt-sdk-1.1.2

    Is there a step-by-step, TOTALLY NOOB-FRIENDLY guide anywhere on how to deploy applications built in the Qt Creator, statically or dynamically? I mean hold-my-hand walk-through style. Please don't link me to the top 20 Google results for this, because I've already tried literally EVERY SINGLE LINK I got from Google searches on this topic, and none of the instructions on them worked or I couldn't figure out how to follow them. When people say things like "make sure your path is properly set," I have no idea what that means or how to do it. It took me all of 2 hours to write the whole program and learn enough Qt to bring it to GUI form, but 6 days and I still can't make a distributable executable. Help!
    Last edited by Pyrrha; 12th August 2011 at 01:50.

  2. #2
    Join Date
    Aug 2011
    Posts
    5
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: How to create finished executable?

    Here is the most common tutorial I find, and this is where I get stuck on it.

    *Installed QtSDK 4.7.3 for Windows. Working on Windows 7 64-bit Professional.

    TUTORIAL 1:
    URL: doc.qt.nokia.com/qq/qq10-windows-deployment.html

    1. Open a command prompt and enter the following:

    cd %QTDIR%
    configure -static <any other options you need

    What I did:
    cd C:\QtSDK (there is no C:\Qt)
    configure -static

    Output:
    'configure' is not recognized as an internal or external command, operable program or batch file.

    What I did:
    Searched the QtSDK directory for 'configure'
    Search returned:
    C:\QtSDK\Symbian\tools\sbs\win32\mingw\info\config ure.info

    C:\QtSDK\Symbian\tools\gcce4\share\doc\symbian-adt-arm-none-symbianelf\html\gdb\Configure-Options.html
    C:\QtSDK\Simulator\Qt\mingw\configure.cache


    END OF ATTEMPT

    I cannot figure out the appropriate place to run this command in.

    TUTORIAL 2:
    URL: cartan.cas.suffolk.edu/qtdocs/deployment-windows.html
    URL: doc.qt.nokia.com/latest/deployment-windows.html
    URL: qt.developpez.com/doc/4.7/deployment-windows/

    1. Open a command prompt and enter the following:
    cd C:\path\to\Qt
    configure -static <any other options you need

    What I did:
    cd C:\QtSDK (there is no C:\Qt)
    configure -static

    Output:
    'configure' is not recognized as an internal or external command, operable program or batch file.


    END OF ATTEMPT

    TUTORIAL 3:
    URL: qtnode.net/wiki?title-Building_static

    1. To use static linking, you must first rebuild Qt to enable static linking.
    2. To build a static app, use CONFIG += static inside your project (.pro) file.
    Opened proejct in Qt Creator.

    Double-clicked RPC.pro (my project filename)
    Added CONFIG += static.
    Saved.

    Still received dll error.
    3. To build a static lib that uses qt, use CONFIG += staticlib inside your project (.pro) file.
    Added CONFIG += staticlib to RPC.pro
    Still received dll error.
    4. You may have to build the Qt library itself to be able to link Qt statically to your application. Before you compile Qt, when configure, use the -static option to enable static builds:
    prompt> configure -static [other configure options]
    Still not certain where to run this command.

    End of attempt.
    Last edited by Pyrrha; 12th August 2011 at 01:40.

  3. #3
    Join Date
    Aug 2011
    Posts
    5
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: How to create finished executable?

    Well I've successfully created a standalone executable. Here's how I got there.

    I was unable to accomplish this with the QtSDK 4.7.3 setup I had. Instead, I uninstalled it, and installed an older version of QtSDK (2009.05) found here.

    I attempted to run the usual configure -static and mingw32-make, but I received errors in the console as well as during attempts to compile my project afterwards.

    Then I found this page and tried running those commands. I didn't get any errors, and my project compiled successfully, but running the executable still caused it to complain of a missing mingwm10.dll.

    Then I found this page, and tried mixing those commands with the previous ones. This succeeded, and allowed me to build my standalone executable.

    In summary, this is what worked (succeeded in both Windows Vista Home Premium 64-bit and Windows 7 Professional 64-bit):

    1. Install QtSDK (2009.05)

    2. Open your mkspecswin32-g++qmake.conf file (located in C:\Qt\2009.05\qt\mkspecs\win32-g++\qmake.conf) in an editor like notepad.

    3. Find the line that starts with "QMAKE_LFLAGS = -enable-stdcall-fixup..." and ddd the phrase "-static" (without quotes) after the "=" sign and before the "-enable..." phrase, so it looks like:
    QMAKE_LFLAGS = -static -enable-stdcall...

    4. Save and close this file.

    5. Set your environment variables. Right-click Computer >> Properties >> Advanced System Settings >> Click the "Environment Variables..." button.

    6. Under "User variables," make sure QTDIR is set to your Qt path (C:\Qt\2009.05\qt). Make sure QMAKESPEC is set to win32-g++.

    7. Under "System variables," edit the one called "Path." Add a semicolon ( ; ) to the end, and add the following:
    C:\Qt\2009.05\mingw\lib;C:\Qt\2009.05\mingw\bin;C: \Qt\2009.05\qt\bin

    8. When finished, relog or reboot.

    9. Open a command prompt.

    10. Change to your Qt directory by entering: cd C:\Qt\2009.05\qt

    11. Enter the following: configure -static -no-phonon -no-phonon-backend -release -no-exceptions

    12. When it asks which edition you want to use, enter "o" for open source.

    13. When it asks you to accept the terms of the license, enter "y" for yes. This will take around maybe 10 minutes to complete.

    14. When that finishes, enter the following: mingw32-make sub-src

    15. Go out to dinner, this will take a while (took between 1-2 hours for me).

    16. When this finishes, open your project in the Qt Creator.

    17. Double-click the project (.pro) file to open it in edit mode.

    18. Add the following line: CONFIG += static

    19. Change your build target to release mode.

    20. Build your project.

    21. Navigate to your release directory and voila! Your standalone executable should be there.

    *NOTE: Some stuff doesn't work with static linking, like plugins, so you can't use static linking for everything.
    Last edited by Pyrrha; 13th August 2011 at 15:46.

  4. #4
    Join Date
    Aug 2009
    Location
    Belgium
    Posts
    310
    Thanks
    10
    Thanked 31 Times in 25 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: How to create finished executable?

    Nice work.

    On a different computer, I think you still have to put mingwm10.dll in the path of your exe though.

    Just one side remark : there are some licensing restrictons when you build Qt statically. See this post for more info.

    Regards,
    Marc

  5. #5
    Join Date
    Jul 2011
    Posts
    18
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: How to create finished executable?

    If you just want to send an excutable around, using something simple like: http://www.jrsoftware.org/isinfo.php
    just point the outputted binaries (.dlls or .lib files) and this will pack them up in to an installer.

  6. #6
    Join Date
    Mar 2011
    Location
    Coimbatore,TamilNadu,India
    Posts
    382
    Thanks
    10
    Thanked 13 Times in 12 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: How to create finished executable?

    I have followed your steps and i got following errors:

    Qt Code:
    1. c:\Qt\2010.03\qt\lib/libQtGui.a(qapplication.o):qapplication.cpp:(.text+0x358a): undefined reference to `_imp___Z21qt_call_post_routinesv'
    2. c:\Qt\2010.03\qt\lib/libQtGui.a(qapplication.o):qapplication.cpp:(.text+0x3b2f): undefined reference to `_imp___Z21qt_call_post_routinesv'
    3. c:\Qt\2010.03\qt\lib/libQtGui.a(qapplication.o):qapplication.cpp:(.text+0x40ca): undefined reference to `_imp___Z21qt_call_post_routinesv'
    4. c:\Qt\2010.03\qt\lib/libQtGui.a(qwhatsthis.o):qwhatsthis.cpp:(.text+0x15c): undefined reference to `_imp___Z21qDeleteInEventHandlerP7QObject'
    5. collect2: ld returned 1 exit status
    6. g++: unrecognized option '-static-enable-stdcall-fixup'
    7. mingw32-make[1]: *** [release\ProgressControl.exe] Error 1
    8. mingw32-make: *** [release] Error 2
    To copy to clipboard, switch view to plain text mode 

    Please help me

  7. #7
    Join Date
    Aug 2011
    Posts
    5
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: How to create finished executable?

    Not sure how much help I can be since I Forrest-Gump'ed my way through this, but I did receive that same error many times in earlier failed attempts. I can't remember which step resolved it, or if it was changing to version 2009.05 that got rid of it. All I can say is this is what worked for me, and I wrote each step down as I completed it when I repeated the entire process on a separate computer. Good luck, and please do post if you find a solution!

  8. #8
    Join Date
    Aug 2010
    Posts
    3
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: How to create finished executable?

    Another option: go to http://qt.nokia.com/downloads and download the last version of qt sdk and the last version of the qt libraries for mingw. Install the sdk first. Second install the qt libraries, it will ask for mingw, you can use the one in the sdk folder or you can download it here.

    Now go to START, QT by nokia and run Qt command prompt. The prompt already points to the qt directory. You should now run:

    Qt Code:
    1. configure -static
    2. make sub-src
    To copy to clipboard, switch view to plain text mode 

    It will take a while to compile. After is done you can use the prompt to cd to your project directory (to go updir use cd ..) and run:

    Qt Code:
    1. make clean
    2. qmake -config release
    3. make
    To copy to clipboard, switch view to plain text mode 

    Don't forget the config += static in the pro file.


    Added after 8 minutes:


    If you want to compile dynamically, just use Qt creator. Make sure you set the buid configuration to release in the project tab and hit ctrl-r.

    Once is done go the compiled folder and run the app. It will say ask for several libs.
    Go to the Qt sdk folder, search then and put then in the compiled folder. It sould work now.
    Last edited by vicbr; 19th August 2011 at 00:42.

Similar Threads

  1. application finished, now what?
    By jbca in forum Newbie
    Replies: 2
    Last Post: 11th August 2010, 06:09
  2. which one has finished with QFutrueWatcher
    By wookoon in forum Qt Programming
    Replies: 2
    Last Post: 27th July 2010, 12:41
  3. How to Create Executable file for my QT application
    By c_srikanth1984 in forum Qt Programming
    Replies: 2
    Last Post: 19th March 2009, 04:02
  4. QProcess::finished()
    By T1c4L in forum Qt Programming
    Replies: 11
    Last Post: 9th July 2008, 20:06
  5. How to create a standalone executable?
    By Ashish in forum Qt Programming
    Replies: 1
    Last Post: 25th January 2007, 15:04

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.