MinGW-w64 offline installer

我只是一个虾纸丫 提交于 2019-11-28 20:49:51

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.

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)

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

    repo-add ./offline.db.tar.gz ./*
    
  5. 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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!