Category: msys

Setting up a 64-bit gcc/OpenMP environment on Windows

Note: This is the part of a series of “how-to” blog posts to help new users and developers of BioFVM and PhysiCell. This guide is for Windows users. OSX users should use this guide for Homebrew (preferred method) or this guide for MacPorts (much slower but reliable). A Linux guide is expected soon.

These instructions should get you up and running with a minimal environment for compiling 64-bit C++ projects with OpenMP (e.g., BioFVM and PhysiCell) using a 64-bit Windows port of gcc. These instructions should work for any modern Windows installation, say Windows 7 or above. This tutorial assumes you have a 64-bit CPU running on a 64-bit operating system.

In the end result, you’ll have a compiler, key makefile capabilities, and a decent text editor. The entire toolchain is free and open source.

Of course, you can use other compilers and more sophisticated integrated desktop environments, but these instructions will get you a good baseline system with support for 64-bit binaries and OpenMP parallelization.

What you’ll need:

  1. MinGW-w64 compiler: This is a native port of the venerable gcc compiler for windows, with support for 64-bit executables. Download the latest installer (mingw-w64-install.exe) here. As of February 3, 2020, this installer will download gcc 8.1.0.
  2. MSYS tools: This gets you some of the common command-line utilities from Linux, Unix, and BSD systems (make, touch, etc.). Download the latest installer (mingw-get-setup.exe) here.
  3. Notepad++ text editor: This is a full-featured text editor for Windows, including syntax highlighting, easy commenting, tabbed editing, etc. Download the latest version here.  As of February 3, 2020, this will download Version 7.8.4.

Main steps:

1) Install the compiler

Run the mingw-w64-install.exe. When asked, select:

Version: 8.1.0 (or later)
Architecture: x86_64
Threads: posix (switched to posix to support PhysiBoSS)
Exception: seh (While sjlj works and should be more compatible with various GNU tools, the native SEH should be faster.)
Build version: 0 (or the default)

Leave the destination folder wherever the installer wants to put it. In my case, it is:

C:\Program Files\mingw-w64\x86_64-8.1.0-posix-seh-rt_v6-rev0

Let MinGW-w64 download and install whatever it needs.

2) Install the MSYS tools

Run mingw-get-setup.exe. Leave the default installation directory and any other defaults on the initial screen. Click “continue” and let it download what it needs to get started. (a bunch of XML files, for the most part.) Click “Continue” when it’s done.

This will open up a new package manager. Our goal here is just to grab MSYS, rather than the full (but merely 32-bit) compiler. Scroll through and select (“mark for installation”) the following:

  • mingw-developer-toolkit. (Note: This should automatically select msys-base.)

Next, click “Apply Changes” in the “Installation” menu. When prompted, click “Apply.” Let the package manager download and install what it needs (on the order of 95 packages). Go ahead and close things once the installation is done, including the package manager.

3) Install the text editor

Run the Notepad++ installer. You can stick with the defaults.

4) Add these tools to your system path

Adding the compiler, text editor, and MSYS tools to your path helps you to run make files from the compiler. First, get the path of your compiler:

  1. Open Windows Explorer ( [Windows]+E )
  2. Browse through C:\, then Program Files, mingw-w64, then a messy path name corresponding to our installation choices (in my case, x86_64-8.1.0-posix-seh_rt_v6-rev0), then mingw64, and finally bin.
  3. Record your answer. For me, it’s
    C:\Program Files\mingw-w64\x86_64-8.1.0-posix-seh-rt_v6-rev0\mingw64\bin\

Then, get the path to Notepad++.

  1. Go back to Explorer, and choose “This PC” or “My Computer” from the left column.
  2. Browse through C:\, then Program Files (x86), then Notepad++.
  3. Copy the path from the Explorer address bar.
  4. Record your answer. For me, it’s
    c:\Program Files (x86)\Notepad++\

Then, get the path for MSYS:

  1. Go back to Explorer, and choose “This PC” or “My Computer” from the left column.
  2. Browse through C:\, then MinGW, then msys, then 1.0, and finally bin.
  3. Copy the path from the Explorer address bar.
  4. Record your answer. For me, it’s
    C:\MinGW\msys\1.0\bin\

Lastly, add these paths to the system path, as in this tutorial. (Note that later versions of the mingw-w64 installer might already automatically update your path.)

5) Test your setup

I wrote a sample C++ program that tests OpenMP parallelization (32 threads). If you can compile and run it, it means that everything (including make) is working! :-)

Make a new directory, and enter it

Enter a command prompt ( [windows]+R, then cmd ). You should be in your user profile’s root directory. Make a new subdirectory, called GCC_test, and enter it.

mkdir GCC_test
cd GCC_test
Grab a sample parallelized program:

Download a Makefile and C++ source file, and save them to the GCC_test directory. Here are the links:

  1. Makefile: [click here]
  2. C++ source: [click here]
Compile and run the test:

Go back to your (still open) command prompt. Compile and run the program:

make 
my_test

The output should look something like this:

Allocating 4096 MB of memory ...
Done!

Entering main loop ...
Done!

Open up the Windows task manager ([windows]+R, taskmgr) while the code is running.  Take a look at the performance tab, particularly the graphs of the CPU usage history. While your program is running, you should see all your virtual processes 100% utilized, unless you have more than 32 virtual CPUs. (This is a good indication that your code is running the OpenMP parallelization as expected.)

Note: If the make command gives errors like “**** missing separator”, then you need to replace the white space (e.g., one or more spaces) at the start of the “$(COMPILE_COMMAND)” and “rm -f” lines with a single tab character.

What’s next?

Download a copy of PhysiCell and try out the included examples! Visit BioFVM at MathCancer.org.

  1. PhysiCell links:
    1. PhysiCell Method Paper at bioRxiv: https://doi.org/10.1101/088773
    2. PhysiCell on MathCancer: http://PhysiCell.MathCancer.org
    3. PhysiCell on SourceForge: http://PhysiCell.sf.net
    4. PhysiCell on github: http://github.com/MathCancer/PhysiCell
    5. PhysiCell tutorials: [click here]
  2. BioFVM links:
    1. BioFVM announcement on this blog: [click here]
    2. BioFVM on MathCancer.org: http://BioFVM.MathCancer.org
    3. BioFVM on SourceForge: http://BioFVM.sf.net
    4. BioFVM Method Paper in BioInformatics: http://dx.doi.org/10.1093/bioinformatics/btv730
    5. BioFVM tutorials: [click here]

Return to NewsReturn to MathCancerFollow @MathCancer
Share this: