20

is there any way to install mingw-w64 offline ? I tried many official sources and all of them seem to need some sort of internet access. I'm looking for something that works for both x32 and x64 systems. I tried to have a look at the official repository but I am not sure which files I need for this task.

Thanks in advance !

Costi Ivan
  • 241
  • 2
  • 4
  • 12
  • 1
    Possible duplicate of [Is there an offline MinGW installer?](https://stackoverflow.com/questions/29028808/is-there-an-offline-mingw-installer) –  Sep 27 '17 at 08:48

4 Answers4

19

Although the following isn't fully tested yet, an offline installer seems unnecessary. Based on some screenshots for a bug report, the online installer asks the following questions...

Version .......... seems to be the GNU GCC version number
Architecture ..... i686 / x86_64
Threads .......... posix / win32
Exception ........ dwarf / sjlj / seh
Build Revision ... 0 / 1 / 2 / ...

Install folder ... e.g. c:\mingw

Create desktop shortcuts?

The first 5 options are used to choose a single download package. I don't know about you, but I've no idea what to choose for threads and exceptions. Based purely on download stats, posix threads are used more than twice as much as win32, seh seems much more popular for 64-bit, dwarf for 32-bit, sjlj seems pretty unloved. I'm guessing 32-bit with posix and dwarf is the default.

To identify what the choices are, it uses a file repository.txt from this folder. That's just a pipe-separated text file - 5 fields for those 5 main options, plus one for the URL of the package to download.

Incidentally, if anyone knows where to find the source code for the installer, I'd really appreciate a comment - I've hunted high and low, found e.g. bug reports, but not found the source of the installer. Sources for mingw-64 binary packages are easy enough to find, though.

The binary packages themselves are in subfolders of this folder (Win32) and this folder (Win64).

I'm not sure what the shortcuts the installer offers to create are for - this is MinGW-w64, not MSYS or MSYS2, so there's no bash-based shell to provide shortcuts to. Probably they're just Windows command prompt shortcuts with the path set up.

Other than that shortcuts issue, all you do is unpack the package to a suitable folder, make sure that the mingw32\bin or mingw64\bin folder is on the path somehow, and you should be done. I've already tested this with one of the 32-bit gcc-5.4.0 packages - g++ compiled a hello-world with no problems.

There are alternative third-party builds in subfolders starting from one step further out here (32 bit) and similar subfolders of different Toolchains targetting * folders for 64-bit and other builds. ray_linn has various builds that include Ada (and Objective C/C++?) support. rubenvb has some older GCC and Clang versions. dongsheng-daily looks like daily builds, even including experimental GCC 7.

If you need MSYS too, let me know in comments. I've been installing that offline (along with MinGW32) for some time, so I have a list of which packages to install. You need quite a few packages, it's a pain getting them from SourceForge, but once you have them it's mostly just unpacking again. There's some minor "postinstall" to do - some file to create, mainly where to find MinGW, plus creating a shortcut to the shell. I have AutoIt scripts to do that - a bit of a mess, using inappropriate methods because they were what I knew in AutoIt at the time, but they work OK.

There's MSYS2, but at first glance that's another online-installing-assumed issue, using the pacman package manager - probably very convenient, but not for the minority who can't use it.

  • Excellent. Thanks for pointing out the repository.txt file. I copied the url for the version want, and pasted it into a browser to download the .7z file. Then I moved it to an offline PC via sneakerNet, and unzipped it. gFortran runs. – riderBill Sep 14 '17 at 02:07
  • I ran mingw-w64-install.exe on my (online) laptop. There are four files in the top level directory from the install that aren't in the .7z file: uninstall.exe, uninstall.ini, mingw-w64, and mingw-w64.bat. mingw-w64 is a shortcut. mingw-w64.bat adds the bin directory to the PATH and opens a cmd window. More interesting, *Windows Uninstall or change program* shows the newly installed MinGW-W64. Windows wouldn't know about MinGW-W64 if the installer hadn't put something in the registry, right? What do you suppose that's about? – riderBill Sep 14 '17 at 02:27
  • @riderBill - sorry, I think you're right about the registry for the uninstaller, but I'm not using this offline "install" now. As far as I remember the official MinGW32 and MSYS installers also did whatever they needed to to register an uninstaller, but that was the only registry use and if I'm "installing" it myself it doesn't bother me "uninstalling" it (deleting the folders) myself too. Now, I don't program in Windows much ATM, but I bought a win7pro license specifically to run in a virtual machine within Linux so I can let it go online and I run MSYS2 (occasionally) on that. –  Sep 14 '17 at 15:50
  • Registering an uninstaller makes sense. Why didn't I think of that? <:^| – riderBill Sep 19 '17 at 00:28
16

Yes, you can install mingw-w64 offline if you use MSYS2's pacman on your internet-facing machine first, then transfer the files downloaded by pacman to your offline machine.

To your question, the great thing about pacman is it will grab the right versions of all dependencies.

On your internet-facing machine:

  1. Use MSYS2 installer from http://www.msys2.org/

  2. Run MSYS2, and update the package database with pacman -Syu

  3. In your MSYS2 terminal, create a folder to contain the packages you want (i.e. mingw-w64)

  4. pacman will not download the packages with all of its dependencies resolved. You'll want to create a temporary blank database

    mkdir ~/offline_packages
    cd ~/offline_packages
    mkdir database
    pacman -Syw --cachedir . --dbpath database base base-devel mingw-w64-x86_64-toolchain 
    
  5. Use pacman's repo-add script to bundle up everything into a database:

    repo-add ./offline.db.tar.gz ./*
    
  6. Copy the MSYS2 installer AND ~/offline_packages to your external flash drive.

On your offline machine:

  1. Install MSYS2.

  2. Copy the offline_packages folder from your flash drive to a path MSYS2 can access (e.g. C:/msys64/home/user/offline_packages)

  3. Edit C:/msys64/etc/pacman.conf

    1. Comment out the [mingw32], [mingw64], [msys] repositories.

    2. Add a new repository. This example uses the arbitrary path given above. Modify to point to wherever you copied the offline_packages folder.

      [offline]
      SigLevel = Optional
      Server = file:///home/user/offline_packages
      
  4. In an MSYS2 terminal, synchronize the pacman database with your new repository

    pacman -Syu
    
  5. Install mingw-w64, etc.

    pacman -S --needed base base-devel mingw-w64-x86_64-toolchain
    
  6. Done!

References: https://wiki.archlinux.org/index.php/Pacman/Tips_and_tricks#Installation_and_recovery

Berkay
  • 23
  • 1
  • 5
AaronDanielson
  • 2,230
  • 28
  • 29
  • My issue with this when I wrote my answer would have been that my only internet-facing machines ran Linux. I seems odd to have a situation where a package manager that (I think) originated in the *nix universe may be more difficult to use there, even for this weird corner-case (but impressive if it turns out not to be). ATM I have a couple of Win7 internet-facing virtual machines, though, and these tips definitely look useful for me. –  Oct 17 '17 at 15:18
  • 1
    Well, this process worked just great with a Windows 7 internet-side and Windows 10 VDI side. I've been using Cygwin for years and years, but there are just some things that Cygwin don't play and MSYS64 is the right solution. – Nufosmatic Oct 13 '19 at 18:33
  • Where are the macro-package contents for "base" "base-devel" "mingw-w64-x86_64-toolchain" defined? – Nufosmatic Oct 13 '19 at 21:55
  • @Nufosmatic: The MSYS2 repos for "[base](https://packages.msys2.org/group/base)", "[base-devel](https://packages.msys2.org/group/base-devel)", and "[mingw-w64-x86_64-toolchain](https://packages.msys2.org/group/mingw-w64-x86_64-toolchain)" are all _groups_, so they're defined at the [MSYS2 groups page](https://packages.msys2.org/group/). (Related, the corresponding Arch groups are given here: "[base](https://www.archlinux.org/groups/x86_64/base/)" and "[base-devel](https://www.archlinux.org/groups/x86_64/base-devel/)", in the [Arch groups overview page](https://www.archlinux.org/groups/) ). – AaronDanielson Oct 14 '19 at 19:28
1

@AaronDanielson's answer is good but it worked for me with a little modification.

At step 5., don't list .sig files or db folder because it result in an error. Use instead for example:

repo-add ./offline.db.tar.gz $(ls -I "*.sig" | grep pkg)
Eric Aya
  • 69,473
  • 35
  • 181
  • 253
ThibaudP
  • 11
  • 1
  • It would be better if you made your answer complete by posting the whole answer. – Rohit Gupta Mar 22 '23 at 20:05
  • I asked for somebody with enough reputation to edit AaronDanielson answer with my modification. But Eric Aya removed this part of my answer, I don't know why. Feel free to do so, I believe it is better to edit the original good answer than to copy everything with only one little adjustment. – ThibaudP Mar 23 '23 at 22:31
  • There is a voting process for edits. And I too had voted (or would have voted) for it to be left alone. Editions are for corrections of mistakes, not to change someone else reply or to make your own reply. – Rohit Gupta Mar 23 '23 at 22:49
  • Ok I understand, I will edit my answer. But I though this was indeed a correction of mistake, as the steps described in the above answer don't work (for me). – ThibaudP Mar 25 '23 at 10:52
0

Don't need to use minGW-w64 only

As the download page of minGW-w64 says:

The heart of the Mingw-w64 project is headers and support libraries to run the output of GCC on Windows. Since Mingw-w64 is neither the home of GCC nor of binutils, several sets of installation packages which combine them are available.

In addition, the sources are available but most people will want to grab binaries directly..

MinGW

Look release of MinGW in github repo from this link. Download you version and copy files in C:\MinGW\.

w64devkit

This option is another alternative which is so good and updated. Look inside releases and choose your version. there is also an installation guide in Readme.md. Download your desired version from this link.

Alijvhr
  • 1,695
  • 1
  • 3
  • 22