Results 1 to 11 of 11

Thread: making a portable binary on windows

  1. #1
    Join Date
    Jan 2006
    Posts
    46
    Thanks
    13
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default making a portable binary on windows

    hey all,
    I have my application up and running ok. The only problem is that when I execute the .exe on another machine it doesn't work unless I install Qt4+MinGW. So my question is how can I compile my Qt app so that it contains the necessary Qt and MinGW dlls or is there are there tutorials I missed online?

    thanx in advance

    Pat

  2. #2
    Join Date
    Jan 2006
    Posts
    667
    Thanks
    10
    Thanked 80 Times in 74 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: making a portable binary on windows

    Why dont you ship Qt 4 + minGW dlls along with your exe ?

  3. #3
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: making a portable binary on windows

    Dependency Walker will tell you what DLLs are required by your application. Just copy proper Qt DLLs and mingw10.dll to the same directory where your executable is and everything should work. If you use Qt plugins, you will have to copy them to proper subdirectories.

  4. The following user says thank you to jacek for this useful post:

    patcito (25th May 2006)

  5. #4
    Join Date
    Jan 2006
    Location
    South Carolina, USA
    Posts
    34
    Thanked 4 Times in 4 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: making a portable binary on windows

    When you compile a program with Qt and basically any compiler your program will be dependent on some dlls provided by Qt and the compiler.

    For example if you compile a very basic Qt Application that only has a main window and pop up screen with mingw32-gcc-3.4.2 and Qt 4.x.x you would need to distribute the following dlls with your application for it to work on another computer.

    I think this is all of them you would need. You might also need another microsoft dll as well. It has been a while since I compiled a program for another comptuer with mingw. But this should give you the basic idea.

    mingwm10.dll
    QtCore4.dll
    QtGui4.dll

    For example if I compile with Visual Studio 2005 instead of mingw I might need to distrubute msvcp80.dll with my application instead of mingwm10.dll.

    You can use depends.exe to see all of the DLLs your program needs to run. The program can be found here: http://www.dependencywalker.com/

    Note that it will show a large list. Most of the DLLs will already be on the target system as they are a part of windows. You will simply need to look for the Qt DLLs and the mingwm10 one. If you forget one when you try running the program on a target machine it should tell you which DLL it can not find.

    Also if you never plan on having any kind of plugins or anything for your program you can rebuild Qt in static mode. This will compile everything into the executable (Qt speaking). You will still need to include the DLL from your compiler, however, you will not need to distribute the Qt DLLs as well.

    I hope this helps you.

  6. The following user says thank you to michael for this useful post:

    patcito (25th May 2006)

  7. #5
    Join Date
    Jan 2006
    Posts
    73
    Thanks
    16
    Thanked 3 Times in 3 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: making a portable binary on windows

    Can the compiler library (mingwm10.dll, msvcp80.dll..) be compiled statically as well?Maybe it is not a good idea?

  8. #6
    Join Date
    May 2006
    Posts
    788
    Thanks
    49
    Thanked 48 Times in 46 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: making a portable binary on windows

    I have write this question on mingw forum...
    The answer....

    >>>>
    You should search the mailing list archives as this is asked every 6 months or so.

    The answer is that any multi-threaded C++ app that uses exceptions must be compiled with -mthreads, and enabling this switch adds a dependency on mingwm10.dll and there is absolutely no way around that. It cannot be made static, due to how it works. If you make your app single-threaded and/or you disable exceptions (-fno-exceptions) then you could probably get away without needing -mthreads.
    <<<<<

    Now my question how disable -mthreads on pro file QMAKE_LFLAGS ??

  9. #7
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: making a portable binary on windows

    Quote Originally Posted by patrik08
    Now my question how disable -mthreads on pro file QMAKE_LFLAGS ??
    You could just set a new value for this variable, but AFAIK you can't compile Qt 4 without it.

  10. #8
    Join Date
    Jan 2006
    Location
    Earth (Terra)
    Posts
    87
    Thanks
    4
    Thanked 6 Times in 4 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows Symbian S60

    Default Re: making a portable binary on windows

    You used to be able to configure Qt to build static libs. I presume you can still do that.(? - I'm not at a machine I can check...)

    If you can get the mingw source and build configuration, you should be able to create static mingw libs.

    Threads don't matter whether static or dll, as far as I know.

    Ditto for any other third party libs.

    You're definitely probing outside the box, it will require you to do a lot of building on your own, but it should be possible. Whether it's worthwhile vs. just distributing the .dlls or not is another question. It can be a lot of work.

    rickb

  11. #9
    Join Date
    May 2006
    Posts
    788
    Thanks
    49
    Thanked 48 Times in 46 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: making a portable binary on windows

    <<<If you can get the mingw source and build configuration, you should be able to create static mingw libs.>>>>

    Yes i can build libs but the code from mingw is so large....... wahts file take????


    OK MingW impossibel!.....

    You think Borland Compiler is Better to make portable exe .....? or Other Window compiler....
    Last edited by patrik08; 27th May 2006 at 21:23.

  12. #10
    Join Date
    Jan 2006
    Location
    Earth (Terra)
    Posts
    87
    Thanks
    4
    Thanked 6 Times in 4 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows Symbian S60

    Default Re: making a portable binary on windows

    Quote Originally Posted by patrik08
    <<<If you can get the mingw source and build configuration, you should be able to create static mingw libs.>>>>

    Yes i can build libs but the code from mingw is so large....... wahts file take????


    OK MingW impossibel!.....
    It would be a matter of reconfiguring the make file/project to create static libs. They might provide a configuration to do that. I haven't gotten into mingw, so can't tell you.

    You think Borland Compiler is Better to make portable exe .....? or Other Window compiler....
    Not sure what you mean by 'portable'. If the systems are configured identically, one exe should work on all, but you may have to pull over the extra pieces, like dlls, etc., if the .exe is not fully resolved on its own.

    Back in the old days, we used to have hot debates about Borland vs. Microsoft. In the end, we wound up with the Microsoft compiler, because we knew that's what the OS was built with, what Windows was built with, and we wouldn't have any compatibility issues, especially with kits like MFC. And MS was naturally ahead of the curve on anything Windows.

    Since you're using mingw, it shouldn't matter, frankly. (I presume you're not using the cygwin mingw, which brings in whole other issues.)

    I'm using the MS compiler, because I still have to use MS toolkits.

    rickb

  13. #11
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,518 Times in 1,388 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: making a portable binary on windows

    Give this a try:
    Qt4 with Visual Studio and static C runtime

    PS. There's a free version of VS2005 (express) out there..
    J-P Nurmi

Similar Threads

  1. Qt and windows vista
    By munna in forum General Discussion
    Replies: 8
    Last Post: 11th January 2006, 22:33

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.