InstallingMinGW - adda-team/adda GitHub Wiki

Basic installation

To be able to compile ADDA on Windows you need to install MinGW-w64 and MSYS. Other compilers are mentioned in the end of this file. Alternatively, we had a limited success with MSYS2, which automates package installation, but has some limitations.

  • Dowload and run MinGW-w64 installer.
  • It will propose the latest version and other default options. Important, change Architecture to x86_64 to compile native 64-bit application (see below for 32-bit options). Choice of Threads and Exceptions does not seem important for ADDA, but will affect the DLLs to be distributed together with ADDA executable. The default choice (posix and seh, respectively) is used for releases since version 1.4.
  • It will propose the default installation folder inside C:\Program Files\mingw-w64. We recommend to remove Program Files\ from this path, so the installation will be in C:\mingw-w64.
  • Further installation will proceed automatically and should install all necessary compiler components, including gfortran and gdb.

MSYS is a collection of 32-bit Unix system utils, such as make and awk, which work fine with both 32- and 64-bit Windows. To install it we recommend the second option from MinGW-w64 instructions:

  • Download the latest full MSYS package (zip archive) from this repository. Currently, it is the one dated 23.11.2011 and is not expected to be updated.
  • Extract the archive into C:\, then everything will be located in C:\msys\
  • Instructions include running C:\msys\postinstall\pi.bat, but that does not seem necessary.
  • (Optional for MSYS shell) Mofify C:\msys\etc\profile:
    • Remove cd "$HOME" at the end. This will help when executing sh --login to open shell at the desired path.
    • Replace HOME="/home/$LOGNAME" with HOME="$USERPROFILE". In particular, this will make global git config visible inside this shell. The only potential drawback is that the new home folder will be shared with, e.g., Git Bash (see below). Together with this change:
      • If you already have any meaningful files in the MSYS home folder, copy them to the Windows home folder ($USERPROFILE).
      • Otherwise consider renaming C:\msys\etc\inputrc.default to inputrc, or to $USERPROFILE\.inputrc (shared with other shells). The latter is exactly, what is done inside profile if the home directory does not exist.

Finally, setup the environment:

  • Add C:\msys\bin and corresponding mingw-w64 folder, e.g. C:\mingw-w64\x86_64-8.1.0-posix-seh-rt_v6-rev0\mingw64\bin, to Windows environmental variable PATH.

Now you are ready to compile ADDA from a console. The only drawback of the concise procedure, described above, is that you need to manually specify include and library paths for external packages, such as FFTW3, in makefiles.

Concerning the consoles, we have tested standard cmd, as well as sh from C:\msys\bin. There are some issues with other ones:

  • Built-in console of Far Manager (v3.0 x64) breaks the compilation, since it somehow cause modification of $(MAKE) in Makefile. A workaround is to run sh -c "make ...".
  • Git Bash (installed with Git for Windows) breaks compilation in OpenCL mode, probably due to some inconsistent handling of line endings when sed ... is applied to oclkernels.cl in ocl/Makefile.

Advanced options

These options may be of interest to developers or to those, who plan to compile ADDA many times with different options. These steps should be performed after the basic steps, described above.

Make sure that all necessary external packages are installed, such as FFTW3, MPI, OpenCL, clFFT, or clBLAS. Those that have Windows installers, usually make the corresponding DLLs available directly (i.e. they are placed in C:\Windows\System32 or their folder is included in PATH). Otherwise, we recommend to:

  • Extract the packages inside C:\msys\local\ (create these folders if necessary) - place each package inside a folder with name including the version to facilitate further updates.
  • Add the folders containing packages DLLs, such as ...\bin to the environmental variable PATH. Thus, the produced ADDA executables can be moved freely around the file system without DLLs.

To avoid need to manually specify include and library paths for external packages in makefiles, do the following (partly based on MinGW instructions):

  • The folders C:\msys\local\include and C:\msys\local\lib need to exist and contain headers and libraries of external packages, respectively. The recommended option is to keep packages intact but create symbolic links (using 64-bit console with administrative privileges), for example:
    cd C:\msys\local
    mklink /D include\fftw ..\fftw-3.3.5
    mklink lib\libfftw3.dll ..\fftw-3.3.5\libfftw3-3.dll
    mklink lib\OpenCL.dll C:\Windows\System32\OpenCL.dll
    mklink /D include\clfft ..\clFFT-2.12.2\include
    mklink lib\clFFT.dll ..\clFFT-2.12.2\bin\clFFT.dll
    mklink /D include\clblas ..\clBLAS-2.12.0\include
    mklink lib\clBLAS.dll ..\clBLAS-2.12.0\bin\clBLAS.dll
  • Locate the library folder of your gcc installation, its path (<gcclib-path>) should be like
    C:\mingw-w64\x86_64-8.1.0-posix-seh-rt_v6-rev0\mingw64\lib\gcc\x86_64-w64-mingw32\8.1.0`
    
  • Look for file specs in folder <gcclib-path>. If it does not exist, execute in this folder
    gcc -dumpspecs > specs
    
  • Modify specs file:
    • Add the following to the beginning:

      *local_prefix:
      c:/msys/local/
      
      *local_incl:
      %(local_prefix)include
      
      *local_includes:
      -I%(local_incl)/fftw -I%(local_prefix)/OpenCL-Headers -I%(local_incl)/clfft -I%(local_incl)/clblas 
      
      *local_lib:
      %(local_prefix)lib
      
      *local_lib_search:
      -L%(local_lib)
      
    • Add %(local_includes) to end of definition for cpp, changing it to, e.g.,

      *cpp:
      %{posix:-D_POSIX_SOURCE} %{mthreads:-D_MT} %(local_includes)
      
    • Add %(local_includes) to end of definition for cc1plus, changing it to, e.g.,

      *cc1plus:
      %(local_includes)
      
    • Add %(local_lib_search) to end of definition for link_libgcc, changing it to, e.g.,

      *link_libgcc:
      %D %(local_lib_search)
      

Notes on 32-bit Windows

Since version 1.4 we do not provide 32-bit executables, since some of the external libraries, such as clFFT and clBLAS, are not immediately available in this format. Moreover, we believe that it is overall a bad idea to run ADDA on such systems due to limited available RAM. However, there are no principal internal limitations in ADDA. Therefore, if you really want to compile ADDA for 32 bit Windows, that is possible. We give brief notes on that in the following:

  • Follow the above guidelines for 64-bit Windows, but select the MinGW-w64 toolchain with Architecture set to i686.
  • All external libraries should be for 32-bit Windows. If you can't find some libraries either compile them yourself or avoid them by compilation options.
  • If you compile 32-bit executable in 64-bit Windows and use system DLLs for linking (e.g. OpenCL.dll), use the ones from C:\Windows\SysWOW64 instead of C:\Windows\System32.

Multilib configuration is, in principle, possible, i.e. to compile both 32- and 64-bit executables from a single machine. Look at the previous version of this wiki page for detailed, but somewhat outdated instructions. The additional complication is that a multilib toolchain of MinGW-w64 is required, containing both 32- and 64-bit versions of all libraries. They are available, but are updated not that often. So an easier option will be:

  • Install two separate MinGW-w64 toolchains, targeting 32- and 64-bit, as described above.
  • Do not put paths to bin folders of these toolchains into the system PATH. Instead, add an appropriate toolchain (path) inside the console immediately before the compilation.
  • Place 32-bit libraries (or links to them) into C:\msys\local\lib32 instead of lib.

Other compilers

Using a different compiler should be easy if it uses the same MinGW-w64 framework and the corresponding system libraries, although we do not have experience with that. By contrast, using compilers based on Visual Studio implementation of system libraries leads to many problems with respect to existing Makefile. A popular compiler of this type is the Intel compiler (for Windows), both Classic and new oneAPI versions. We provide a workaround batch script for that (src/iw_compile.bat), which provides the simplest ADDA compilation (corresponding to make seq). Look inside this script for details on its usage, including the installation of Intel compilers and Visual Studio environment.

⚠️ **GitHub.com Fallback** ⚠️