Results 1 to 8 of 8

Thread: Can a Qt program compiled on Linux run on windows?

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,332
    Qt products
    Qt5
    Platforms
    Windows
    Thanks
    317
    Thanked 871 Times in 858 Posts

    Default Re: Can a Qt program compiled on Linux run on windows?

    So I'm still confused.

    Unfortunately the precompiled 64-bit Qt development environment for Windows is only available for Microsoft compiler and thus cannot be used with MinGW64.
    So if you can't get that, then how can you do this:

    When cross-compiling for Windows 64 bit it is much easier to get a development environment: Just install what you need from the distribution repositories.
    If there is no pre-built Mingw64 version of Qt for Windows, then what is there to download and from which repositories besides the cross-compiler and the libraries it provides?

    For cross-compiling the application you only have to take care that the cross compiler and the corresponding libraries are used.
    Right. In order to build a Windows EXE, you must link to the Windows / Mingw64 versions of the Qt link-library .LIB files (which correspond to the .DLL files the app will load when it actually runs on Windows). Which is why I asked if you could:

    simply copy the .lib files over to the linux PC for linking?
    instead of building the Qt link libraries (and DLLs) on linux using the cross-compiler. A binary file is a binary file, so the linker shouldn't care if you built it on linux using the cross-compiler or on Windows using the native Mingw64 compiler.

    Of course, if there is no Mingw64 for Qt on Windows then it is a moot point, but the same principle should apply no matter which library you need to link to.
    <=== The Great Pumpkin says ===>
    Please use CODE tags when posting source code so it is more readable. Click "Go Advanced" and then the "#" icon to insert the tags. Paste your code between them.

  2. #2
    Join Date
    Oct 2009
    Location
    Germany
    Posts
    120
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Thanked 42 Times in 41 Posts

    Default Re: Can a Qt program compiled on Linux run on windows?

    Hello,

    for Windows there exists MinGW 64 bit compiler. You can download one e.g. from http://http://tdm-gcc.tdragon.net/download. However, this is only the compiler, no precompiled Qt environment. For using Qt with this compiler, you have to compile it yourself.

    For Linux there exists MinGW 64 bit cross compiler, i.e. it is a Linux binary that produces code that runs on Windows. For this cross compiler there also exists a precompiled Qt environment. This consists of the libraries, dlls, ... for Windows. These libraries are used by the linker of the cross compiler tool chain to produce the Windows exe file. So on Linux I do not have to compile the Qt cross environment myself. I just install it from the repositories.

    Which is why I asked if you could:

    simply copy the .lib files over to the linux PC for linking?
    instead of building the Qt link libraries (and DLLs) on linux using the cross-compiler.
    Where do you get the .lib files for Qt from? I couldn't find any pre-compiled Qt environment compatible with MinGW64. So what would you want to copy to Linux?

    Again: I do NOT need to compile the Qt libraries and dlls on Linux. They are provided by the Linux repositories. As an example, I have installed the 32 bit environment in a VM running Linux, and it gives me the following files for Qt:
    Qt Code:
    1. /usr/i686-w64-mingw32/sys-root/mingw/bin/QtCore4.dll
    2. /usr/i686-w64-mingw32/sys-root/mingw/bin/QtDBus4.dll
    3. /usr/i686-w64-mingw32/sys-root/mingw/bin/QtDeclarative4.dll
    4. /usr/i686-w64-mingw32/sys-root/mingw/bin/QtMultimedia4.dll
    5. /usr/i686-w64-mingw32/sys-root/mingw/bin/QtNetwork4.dll
    6. /usr/i686-w64-mingw32/sys-root/mingw/bin/QtTest4.dll
    7. /usr/i686-w64-mingw32/sys-root/mingw/bin/QtXml4.dll
    8. /usr/i686-w64-mingw32/sys-root/mingw/bin/QtXmlPatterns4.dll
    9. /usr/i686-w64-mingw32/sys-root/mingw/lib/qt4
    10. /usr/i686-w64-mingw32/sys-root/mingw/lib/qt4/plugins
    11. /usr/i686-w64-mingw32/sys-root/mingw/lib/qt4/plugins/accessible
    12. ...
    To copy to clipboard, switch view to plain text mode 
    Same is available for mingw64 and Qt5, but currently I do not have it installed in my VM.

    Of course, if there is no Mingw64 for Qt on Windows then it is a moot point, but the same principle should apply no matter which library you need to link to.
    As a summary: MinGW64 is running on Windows producing Windows 64 bit exe files. There are no Qt binaries bundled with this compiler.

    Best regards
    ars

  3. #3
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,332
    Qt products
    Qt5
    Platforms
    Windows
    Thanks
    317
    Thanked 871 Times in 858 Posts

    Default Re: Can a Qt program compiled on Linux run on windows?

    OK, I did not understand that there was a Mingw64 cross-compiler and a cross-compiled Qt distribution available on linux platforms.

    Where do you get the .lib files for Qt from?
    You get them from your Windows build of Qt using Mingw64 for Windows. This was said under the assumption that the only way to get a Mingw64-compiled version of Qt was to build it yourself, either on Windows with the native Mingw64 compiler or by cross-compiling on linux using the Mingw64 cross-compiler. In either situation, the .lib and .dll files had better be the same, and so you could either 1) copy the .lib files from Windows (if you built Qt there) to linux for linking (via the cross-compiler) or 2) copy the dlls from linux (if you built or installed Qt there) to Windows for execution.

    BUT, if the Qt lib and dll files are available in lunix repositories in cross-compiled form, then of course none of this is needed. I simply asked if copying the files was possible in case there was nothing there on linux already. I didn't know the answer.
    <=== The Great Pumpkin says ===>
    Please use CODE tags when posting source code so it is more readable. Click "Go Advanced" and then the "#" icon to insert the tags. Paste your code between them.

Similar Threads

  1. Replies: 5
    Last Post: 12th July 2014, 04:07
  2. Replies: 2
    Last Post: 5th October 2010, 08:20
  3. Replies: 3
    Last Post: 20th September 2010, 22:36
  4. Replies: 13
    Last Post: 10th June 2009, 01:56
  5. Program in Windows, Deploy in Linux
    By suitto in forum Installation and Deployment
    Replies: 1
    Last Post: 8th April 2009, 13:11

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
  •  
Qt is a trademark of The Qt Company.