Wiki Page Content

Compiling EMAN2 on Windows

Note: This is a brief instruction for EMAN2 compilation on windows with visual c++. You will get a general idea for how to get EMAN2 compiled on windows. The actual version of these dependent libraries may be different.

1. Use cmake to generate Visual Studio 2008 solution:

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

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

2. The dependent libraries for EMAN2 building:

  • 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.

    set PYTHON_INLCUDE_PATH to C:/Python26/include
    set PYTHON_LIBRARY to C:/Python26/libs/python26.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 bootstrap.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_43_0/bin.v2/libs/python/build/msvc-9.0/release/threading-multi/boost_python-vc80-mt-1_43.lib
  • 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 these commands:

    lib.exe /machine:i386 /def:libfftw3f-3.def
    set FFTW3_INCLUDE_PATH to C:/fftw-3.2.2.pl1-dll32.
    set FFTW3_LIBRARY to C:/fftw-3.2.2.pl1-dll32/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.
    open a Visual Studio 2008 Command Prompt, cd c:\tiff-3.8.2-1-lib\lib
    Run this commands:
    lib.exe /machine:i386 /def:libtiff.def
    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.

    download binary from Save the libtiff3.dll for runtime use.

  • libjpeg

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

    unzip to to C:\jpeg-6b-4-lib.
    open a Visual Studio 2008 Command Prompt, cd c:\jpeg-6b-4-lib\lib
    Run this commands:
    lib.exe /machine:i386 /def:jpeg.def
    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.

    download binary from Save the jpeg62.dll for runtime use.

  • libpng

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

    unzip to C:\libpng-1.2.37-lib.
    open a Visual Studio 2008 Command Prompt, cd c:\libpng-1.2.37-lib\lib
    Run this commands:
    lib.exe /machine:i386 /def:libpng12.def
    copy header files in C:/libpng-1.2.37-lib/include to C:\include, copy C:/libpng-1.2.37-lib/lib/libpng.lib to C:\lib.
    set PNG_INCLUDE_PATH to C:/include.
    set PNG_LIBRARY to C:/lib/libpng.lib.

    download binary from Save the libpng12.dll for runtime use.

  • 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:\zlib\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 into C:/Program Files/Microsoft SDKs/Windows/v6.0A/Include/GL.

    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.
  • FTGL

    Download ftgl-2.1.3-rc5.tar.gz from

    Download from

    set FTGL_INCLUDE_PATH to C:/ftgl-2.1.3~rc5/src
    set FTGL_LIBRARY to C:/Download/ftgl-2.1.3-rc5/ftgl-2.1.3~rc5/msvc/build/ftgl_static_D.lib.
    In "Advance view" mode, set ENABLE_STATIC_FTGL
    set FREETYPE_INCLUDE_PATH to C:/freetype-2.3.5-1-bin/include.
    set FREETYPE_LIBRARY to C:/freetype-2.3.5-1-bin/lib/freetype.lib.
  • Berkeley DB

    The Berkeley DB and the following pybsddb is optional because Python interpreter already have them. But the bsddb comes with Python interpreter is not stable as current release. We STRONGLY suggest you compile and install the current release of Berkeley DB and pybsddb. We do so for all our binary release of EMAN2. The simple way to check whether you have Python's default bsddb or self-compile one: the self-compile one will become bsddb3 in Python. So if you can "import bsddb3" in Python, you have your own berkeley DB installed. Otherwise, you can only do "import bsddb".

    Download Berkeley DB source package (Berkeley DB from oracle Do NOT download the windows installer (Berkeley DB 5.3.21.msi Windows installer), I never get it worked with EMAN2.

    unzip the file.

    Open Visual C++ .NET 2008, Choose File -> Open -> Project/Solution.... In the build_windows directory, select Berkeley_DB.sln and click Open.

    The Visual Studio Conversion Wizard will open automatically. Click the Finish button.
    On the next screen click the Close button.
    Choose Release from the drop-down menu on the tool bar.
    Choose the Win32 platform configuration from the drop-down menu on the tool bar.
    To build, right-click on the Berkeley_DB solution and select Build Solution.
    Look for build results in directory build_windows\Win32\Release.
    You need build_windows\Win32\Release\libdb53.lib for your pybsddb compilation.
    Copy the runtime library libdb53.dll from build_windows\Win32\Release to your EMAN2\lib directory. This is required.
    Copy the executable file from db_archive.exe to db_verify.exe to your EMAN2\bin directory. This is optional. You may need those commands for some diretly bsddb operation if things go wrong.
  • pybsddb

    pyBSDDB is the Python wrapping for Berkeley DB. With this package, you can utilize berkeley DB in Python.

    Download the latest release of pyBSDDB from

    Extract it to get folder which contains pybsddb3 source and setup files, for example \bsddb3-5.3.0 lke I get.
    Create a folder db in \bsddb3-5.3.0.
    Create a folder include in \bsddb3-5.3.0\db, copy following herder files from your Berkeley DB folder to \bsddb3-5.3.0\db\include:
    \dbinc\queue.h clib_port.h db.h db_config.h db_cxx.h db_int.h dbstl_common.h
    Create a folder bin in \bsddb3-5.3.0\db, copy executable file from db_archive to test_cutest and libdb*.dll to this \bsddb3-5.3.0\db\bin directory.
    Create a folder lib in \bsddb3-5.3.0\db, copy following libraries from your Berkeley DB's build_windows\Win32\Release\libdb53.lib to \bsddb3-5.3.0\db\lib directory.
    This is the tricky part, copy the \bsddb3-5.3.0\db\lib\libdb53.lib in the same folder as \bsddb3-5.3.0\db\lib\libdb53s.lib, it's needed in the later on compilation.
    Open visual studio 2008 command prompt, cd into folder \bsddb3-5.3.0
    Use an editor, open, comment out following three lines:
        assert (fullverstr[0], fullverstr[2]) in db_ver_list, (
            "pybsddb untested with this Berkeley DB version", ver)
        print 'Detected Berkeley DB version', ver, 'from db.h'
    and this line:
        runtime_library_dirs = [ libdir ],
    Run following command:
    python.exe bdist --formats=wininst
    python.exe install
    Congratulations! Now you have your Berkeley DB and pyBSDDB installed. You can check their version in Python to confirm you have successfully installed them:
     import bsddb3
     bsddb3.__version__     #this is the pyBSDDB version
     bsddb3.db.version()    #this is the Berkeley DB version

3. Actions before build:

  • In cmake configuration page, you need change the CMAKE_CONFIGURATION_TYPES to Release.
  • If you did not configure the build type to Release in cmake. In the Visual Studio 2008 menu, choose build -> configuration manager. Set the "Active Solution Configureation" to release. 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. After compilation

  • We need copy the runtime libraries into EMAN2/lib directory.
  • boost_python-vc90-mt-1_43.dll
    jpeg62.dll, duplicate it to jpeg.dll
    libtiff3.dll, change the name to libtiff.dll

5. Install runtime libraries

6. Set up environment varaibles

set EMAN2DIR to C:\EMAN2
set PATH to C:\EMAN2\bin;C:\EMAN2\lib
set PYTHONPATH to C:\EMAN2\lib

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.

COMPILE_EMAN2_VS2008 (last edited 2012-08-13 19:52:54 by gtang)