Wiki Page Content

Revision 3 as of 2010-06-16 19:03:15

Clear message

Compiling EMAN2 on Windows

  1. Use cmake to generate Visual Studio 2008 solution:

  • Download cmake windows installer cmake-2.8.1-win32-x86.exe from

  • run cmake, choose generation solution for visual 2008, fill the EMAN2 source directory to "Where is the source code", and specify a directory to "Where to build the binaries".
  • Specify the CMAKE_CONFIGURATION_TYPES to release.
  • click configure button, then click OK. You will get error dialog. Then follow the next item to solve all dependency libraries.

  1. Install and configure the dependent libraries:

  • Note: I suppose all packages are installed on C: drive. You can adjust it according to your actual path.
  • Python

    Download python-2.6.5.msi from, run it to install.

    In cmake, set PYTHON_INLCUDE_PATH to C:/Python25/include
    In cmake, set PYTHON_LIBRARY to C:/Python25/libs/python25.lib
  • Numpy

    Download numpy-1.4.1-win32-superpack-python2.6.exe from, run it to install.

    set NUMPY_INCLUDE_PATH to C:/Python26/Lib/site-packages/numpy/core/include
  • Boost.python

    Download and from

    unzip, you will get a executable file bjam.exe, put this file in your PATH(make sure you can execute it in a console window).
    open a Visual Studio 2008 Command Prompt, cd C:\boost_1_43_0
    run booststrap.bat
    bjam --with-python toolset=msvc link=shared threading=multi runtime-link=shared
    set the BOOST_INCLUDE_PATH to C:/boost_1_43_0/include
    set the BOOST_LIBRARY to C:/boost_1_35_0/bin.v2/libs/python/build/msvc-9.0/release/threading-multi/boost_python-vc90-mt-1_43.lib
    If you got compilation error, "error LNK1104: cannot open file 'boost_python-vc90-mt-1_43.lib'", then you need build boost.python library as shared library.
  • HDF5

    Download from

    unzip, get a folder hdf5lib.
    set the HDF5_INCLUDE_PATH to C:/hdf5lib/include.
    set the HDF5_LIBRARY to C:/hdf5lib/dll/hdf5dll.lib.
  • FFTW3

    Download precompiled fftw3.1.2 windows dlls from

    open a Visual Studio 2008 Command Prompt, cd c:\fftw-3.2.2.pl1-dll32.

    follow the instruction from, run command:

    lib /machine:i386 /def:libfftw3f-3.def
    this create library libfftw3f-3.lib
    set FFTW3_INCLUDE_PATH to c:/fftw-3.2.2.pl1-dll32.
    set FFTW3_LIBRARY to C:/fftw-3.1.2/libfftw3f-3.lib
  • GSL

    Download from

    unzip to C:\gsl.
    set GSL_INCLUDE_PATH to C:/gsl/include.
    set GSL_CBLAS_INCLUDE_PATH to C:/gsl/include.
    set GSL_LIBRARY to C:/gsl/lib/gsl.lib.
    set GSL_CBLAS_LIBRARY to C:/gsl/lib/cblas.lib.
  • libtiff

    Download from, click the zip link close to "Developer files".

    unzip In C drive, create directory include and lib.
    copy header files in C:\tiff-3.8.2-1-lib\include to C:\include, copy C:\tiff-3.8.2-1-lib\libtiff.lib to C:\lib.
    set TIFF_INCLUDE_PATH to C:/include.
    set TIFF_LIBRARY to C:/lib/libtiff.lib.
  • libjpeg

    Download from, click the zip link close to "Developer files".

    unzip to to C:\jpeg-6b-4-lib.
    copy header files in C:\jpeg-6b-4-lib/include to C:\include, copy C:/jpeg-6b-4-lib/lib/jpeg.lib to C:\lib.
    set JPEG_INCLUDE_PATH to C:/include.
    set JPEG_LIBRARY to C:/lib/jpeg.lib.
  • libpng

    Download from, click the zip link close to "Developer files".

    unzip to C:\libpng-1.2.24.lib.
    copy header files in C:/libpng-1.2.24.lib/include to C:\include, copy C:/libpng-1.2.24.lib/lib/libpng.lib to C:\lib.
    set PNG_INCLUDE_PATH to C:/include.
    set PNG_LIBRARY to C:/lib/libpng.lib.
  • zlib

    Download from

    unzip to C:\zlib.
    copy header files in C:\zlib\include to C:\include, copy zlib1.lib and zlib1.dll from C:\zlib123-vs2005\dll to C:\lib.
    set ZLIB_LIBRARY to C:/lib/zlib1.lib.
  • szlib

    Download from

    unzip to C:\szip.
    copy header files in C:\szip\include to c:\include, copy C:\szip\lib\szlib.lib to C:\lib.
    set SZLIB_LIBRARY to C:\lib\szlib.lib.
  • OpenGL

    Download glext.h from

    set GLU_INCLUDE_PATH to C:/Program Files/Microsoft SDKs/Windows/v6.0A/Include.
    set GLU_LIBRARY to C:/Program Files/Microsoft SDKs/Windows/v6.0A/Lib/GlU32.Lib.
    set GL_INCLUDE_PATH to C:/Program Files/Microsoft SDKs/Windows/v6.0A/Include.
    set GL_LIBRARY to C:/Program Files/Microsoft SDKs/Windows/v6.0A/Lib/OpenGL32.Lib.

3. Actions before build:

  • In the Visual Studio 2008 menu, choose build -> configuration manager. Set the "Active Solution Configureation" to release if it's not. Then check the INSTALL and test in the check boxes.

  • right click the "Solution 'EMAN2'" in the left "Solution Explorer" pane, then choose "Build Solution". If you see all 27 projects build succeeded. Then you got a successfull EMAN2 build.

4. Runtime libraries:

  • copying the following runtime libraries into EMAN2/lib directory:
  • boost_python-vc90-mt-1_43.dll
    jpeg62.dll, and copy it as jpeg.dll
    libtiff3.dll, rename it to libtiff.dll

5. Runtime dependents for EMAN2 GUI program

6. Set up Environmental variables

  • Set up following environmental variables:
  • Set EMAN2DIR to C:\EMAN2
    Set PATH to C:\EMAN2\bin;C:\EMAN2\lib
    Set PYTHONPATH to C:\EMAN2\lib

7. Test if EMAN2 works

  • After everything installed, type,
  • If you see error message like, "The procedure entry point _Z7qstrcmpRK10QByteArrayS1_ could not be located in the dynamic link library QtCore4.dll.". That means you may have other Qt4 libraries installed. Remove them, just use the Qt4 libraries come with PyQt4 will solve this problem.

    If you see error message like, "ImportError: DLL load failed: The specified module could not be found.". That means some dependent runtime libraries for libpy***.pyd are missing. Find what's missing and copy it into EMAN2/lib directory.

  • in the prompt, try following command:
  • img = test_image()
    img = test_image_3d()