Compile Bowtie2 on Windows 64 bit.

Bowtie 2 is a program that efficiently aligns next generation sequence data to a reference genome. However, the version distributed by the authors only compiles on POSIX platforms. These instructions will allow you to compile it on windows by downloading the Mingw64 tools and editing the make file before building the program. Instructions
  1. Download the Bowtie 2 source code. Extract the code to a location on your disk.
  2. Download the mingW64 compiler tools. These tools are much easier to use if they are downloaded as a package from this site: TDM Compiler Package. Be sure to select the TDM 64 bit version of the tools.
  3. Run the installer for the package. When prompted, select all of the available packages for installation.
  4. In explorer, navigate to where you unzipped the source code for bowtie. Find the file called Makefile and edit it. A great way to do this is to install the program notepad++. If notepad++ is installed, simply write click on the file and select “edit with notepad++”.
  5. Edit the file so that it knows it is compiling on Ming and Windows. To do this, insert # marks in front of all the if/else statements, so that lines 35 to 53 of the file look like this:
    # Detect Cygwin or MinGW
    #WINDOWS = 0
    #CYGWIN = 0
    #MINGW = 0
    #ifneq (,$(findstring CYGWIN,$(shell uname)))
    #WINDOWS = 1 
    #CYGWIN = 1
    # POSIX memory-mapped files not currently supported on Windows
    #BOWTIE_MM = 0
    #ifneq (,$(findstring MINGW,$(shell uname)))
    WINDOWS = 1
    MINGW = 1
    # POSIX memory-mapped files not currently supported on Windows
    BOWTIE_MM = 0
  6. Now edit the makefile so it points to a correct pthreads library. Edit line 76 so it reads as follows:
    PTHREAD_LIB = -lpthread
  7. Edit the file so that it compiles as 64 bit, change lines 121-132 to the following
    # Convert BITS=?? to a -m flag
    #ifeq (x86_64,$(shell uname -m))
    #ifeq (32,$(BITS))
    #BITS_FLAG = -m32
    #ifeq (64,$(BITS))
    BITS_FLAG = -m64
  8. Go to start->All Programs->MingGW64->MingGW Command prompt
  9. Navigate to the directory with the source code and make file by entering the cd command at the prompt, e.g.
    cd C:\Programs\bowtie2-2.0.6-source\bowtie2-2.0.6 
  10. Type “make” and hit enter.
  11. All done!
  12. Edit: One person had a comment on this, if this doesn’t work you may have to use teh MinGW shell. Edit: It has been pointed out that the BowTie2 team doesn’t use memory mapped files on windows. This might mean large genomes are less performant.

5 thoughts on “Compile Bowtie2 on Windows 64 bit.

  1. Rahul

    I followed all of the above steps and I get the following message:
    ‘make’ is not recognized as an internal or external command, operable program or batch file.

    Do you have any idea how I can get this to work?

    1. nfdelane Post author

      Oh interesting that it didn’t work. I may have some local settings that are not on your machine. Out of curiosity, if you go to Start->All Programs->MinGW->MinGW Shell? If so you can click on that, then change to the directory with your source. This command will be the same as before but use “/” instead of “\”. e.g.

      cd /c/directory/bowtie2/

      then type make. If you don’t see the MinGW Shell I can direct you to where you can install it.

      1. Rahul

        Thank you for your response. I used “mingw-get-inst-20120426.exe” to install MinGW Shell. Then I tried to use the “make” command on the folder with the modified Makefile. It gave me a bunch of errors:
        sorry, unimplemented: 64-bit mode not compiled in

        However, when I ran the “make’ command on an unmodified bowtie2 source it complied fine. I am not sure if I now have 64-bit bowtie2 executables. Do you know how I can tell if I have a 64-bit version?
        Thanks for your help,

        1. nfdelane Post author

          Hi Rahul,

          Yep, you compiled a 32 bit version, which probably works and may be fine for your needs but is not 64 bit and so can’t use as much memory. I will try to explain what is going on with all these difference first before offering a solution.

          When compiling a program like BowTie2, you need a compiler program to take all of the source code and convert it into a .exe file that you can use. For programs that are traditionally written for unix, there are two commonly used compilers. One is MingW for 32 bit windows, which is an earlier compiler program that only does 32 bit compilation. The other is MingW for 64 bit windows, it is a derived (and separate) version of the MingW compiler than the 32 bit program. The programs in each compiler package have similar/identical names, so making sure you are using the right one can be confusing (the joys of unix). You have now downloaded and installed both the 64 bit and the 32 bit programs. You will likely see the same program “g++.exe” in two locations on your hard drive, such as




          This g++.exe program is the one you need to compile bowtie2 and so you need to make sure this program is invoked by the “make” command. Because you installed the shell package for the 32 bit version, you are now by default using the 32 bit version of g++, which cannot compile for 64 bit. To verify which version you are using, inside the mingW shell you can type g++ -v.

          So how to make sure you are using only the 64 bit version? Probably the easiest thing to do if you want to compile on 64 bit is to simply uninstall the entire 32 bit program, both from the start menu and then deleting the MinGW directory where the g++.exe file is located. There can be “zombie” references lingering to the old 32 bit program that can cause problems if it is still around when trying to do a 64 bit compilation.

          After that, install the 64 bit version of the tools including the command prompt. You can do that by going to this page and clicking on the .zip file listed. Unzip this, got into the directory->msys and click msys.bat. verify it is referring to a correct g++ by typing g++ -v. If it is, change to the directory with the edited make file as described before, and type make.


Leave a Reply