Skip to content

Compilation Guide

minh edited this page Nov 14, 2015 · 48 revisions

For advanced users to compile IQ-TREE source code.

Table of Contents

This document gives a compilation guide to build IQ-TREE from source code under Linux, Mac OS X and Windows.

General requirements

  • Make sure that a C++ compiler was installed. IQ-TREE was successfully built with GCC, Clang, MS Visual Studio and Intel C++ compiler.

  • Install CMake if not yet available in your system.

  • Install git if not yet available in your system.

  • If you want to compile the multicore version, make sure that the compiler supports OpenMP and the OpenMP library was installed.

  • Download source code. Since IQ-TREE has a submodule (the phylogenetic likelihood library), the best way to obtain source code is to use git:

      git clone --recursive https://github.com/Cibiv/IQ-TREE.git
    

Compiling under Linux

  1. Open a Terminal.

  2. Change to the source code folder:

     cd PATH_TO_EXTRACTED_SOURCE_CODE
    
  3. Create a subfolder, say, build and go into this subfolder:

     mkdir build
     cd build
    
  4. Configure source code with CMake:

     cmake ..
    

    To build the multicore version please add -DIQTREE_FLAGS=omp to the cmake command:

     cmake -DIQTREE_FLAGS=omp ..
    
  5. Compile source code with make:

     make
    

This creates an executable iqtree or iqtree-omp (iqtree.exe or iqtree-omp.exe under Windows). It can be copied to system search path so that IQ-TREE can be called from the Terminal simply with the command line iqtree.

Compiling under Mac OS X

  • Make sure that clang compiler is installed, which is typically the case if you installed Xcode and the associated command line tools.
  • Find the path to the CMake executable, which is typically /Applications/CMake.app/Contents/bin/cmake.

The steps to compile IQ-TREE is similar to Linux (see above), except that step 4 has to be changed to:

Configure source code with CMake (please change cmake to absolute path like /Applications/CMake.app/Contents/bin/cmake):

cmake -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ ..

To compile the multicore version, the default clang unfortunately does not support OpenMP (which might change in the near future). However, you can obtain and install OpenMP/Clang from https://clang-omp.github.io and the OpenMP library from http://openmp.llvm.org. After that you can run cmake with (assuming that clang-omp points to the installed OpenMP/Clang):

cmake -DCMAKE_C_COMPILER=clang-omp -DCMAKE_CXX_COMPILER=clang-omp++ -DIQTREE_FLAGS=omp ..

Compiling under Windows

The sequential IQ-TREE version was successfully compiled with TDM-GCC from http://tdm-gcc.tdragon.net. Since TDM-GCC is essentially a GCC version for Windows, the compiling steps are like under Linux, except that for step 1, you need to open the Terminal called TDM-GCC-64, which can be assessed from the Start menu.

To build multicore version, please switch to MS Visual Studio and Intel C++ compiler because somehow TDM-GCC caused downgraded performance under our tests. Assuming that you have installed MS Visual Studio 2013 and Intel Parallel Studio XE 2015. Then change the CMake step to:

cmake -G "Visual Studio 12 Win64" -T "Intel C++ Compiler XE 15.0" -DIQTREE_FLAGS=omp ..

This will create solution and projects files for MS Visual Studio inside the build folder. Now exit the command prompt, open Windows explorer and navigate into this build folder. Double-click file iqtree.sln (so-called Visual Studio solution file). This will open MS Visual Studio and load IQ-TREE projects. Build the solution (Menu BUILD -> Build solution or press F7). This creates an executable Release\iqtree.exe. This executable and the .dll files can be copied to your system search path such that IQ-TREE can be invoked from the command line by simply entering iqtree.

Compiling 32-bit version

The compilation guides above will generate 64-bit binaries. To compile 32-bit version instead, simply add m32 into IQTREE_FLAGS of the cmake command. That means, -DIQTREE_FLAGS=m32 to build 32-bit sequential version and -DIQTREE_FLAGS="omp m32" to build 32-bit multicore version.

Clone this wiki locally