Wiki Page Content

Upload page content

You can upload content for the page named below. If you change the page name, you can also upload content for another page. If the page name is empty, we derive the page name from the file name.

File to load page content from
Page name

Compiling EMAN2 on Windows

1. Why don't I recommend Visual Studio 2003 as compiler for EMAN2 on WinXP?

Compile EMAN2 on Windows with Microsoft Visual Studio .NET 2003 may have these problems:
 * "fatal error C1204: Compiler limit: internal structure overflow". There is a solutions in the [ Boost Python FAQ] .
  * For libpyEMData2.cpp, comment out these functions: done_data() update() render_amp8() set_array_offsets() set_array_offsets() get_array_oddsets() and last three "__call__" functions.
  * For libpyUtils2.cpp, split this file to libpyUtils2.cpp and otherUtil.cpp.
NOTE - Removing the functions above will break EMAN2 in several important ways.  So It's better use Visual Studio 2005 to compile EMAN2.

2. Use cmake to generate Visual Studio 2005 solution:

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

  • run cmake, 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.

3. The major trouble of compiling EMAN2 on Visual Studio 2005 come from the dependent library:

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

    Download python.2.5.2.msi from, run it to install.

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

    Download numpy-1.1.0-win32-superpack-python2.5.exe from, run it to install.

    set NUMPY_INCLUDE_PATH to C:/Python25/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 2005 Command Prompt, cd C:\boost_1_35_0\libs\python\build\

    bjam -sTOOLS=msvc "-sBUILD=release <runtime-link>dynamic <optimization>speed"

    set the BOOST_INCLUDE_PATH to C:/boost_1_35_0/include
    set the BOOST_LIBRARY to C:/boost_1_35_0/bin.v2/libs/python/build/msvc-8.0/release/threading-multi/boost_python-vc80-mt-1_35.lib
  • HDF5

    Download from

    unzip, get a folder 5-181-win-vs2005.
    set the HDF5_INCLUDE_PATH to C:/5-181-win-vs2005/include.
    set the HDF5_LIBRARY to C:/5-181-win-vs2005/dll/hdf5dll.lib.
  • FFTW3

    Download precompiled fftw3.1.2 windows dlls from

    open a Visual Studio 2005 Command Prompt, cd c:\fftw-3.1.2-dll.

    follow the instruction from, run these commands:

    lib /machine:i386 /def:libfftw3-3.def
    lib /machine:i386 /def:libfftw3f-3.def
    lib /machine:i386 /def:libfftw3l-3.def 

    Download fftw-3.1.2 source code fftw-3.1.2.tar.gz from

    unzip and untar fftw-3.1.2.tar.gz in a temporary directory, copy the include directory to C:\fftw-3.1.2
    set FFTW3_INCLUDE_PATH to C:/fftw-3.1.2/include.
    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:\zlib123-vs2005.
    copy header files in C:\zlib123-vs2005\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.

    if you get compilation errors complain about <unistd.h> can not be found, change line 287 of zconf.h to "#if 0"

  • szlib

    Download from

    unzip to C:\szip21-vs2005-enc.
    copy header files in C:\szip21-vs2005-enc\include to c:\include, copy C:\szip21-vs2005-enc\lib\szlib.lib to C:\lib.
    set SZLIB_LIBRARY to C:\lib\szlib.lib.
  • OpenGL

    set GLU_INCLUDE_PATH to C:/Program Files/Microsoft Visual Studio 8/VC/PlatformSDK/Include.
    set GLU_LIBRARY to C:/Program Files/Microsoft Visual Studio 8/VC/PlatformSDK/Lib/GlU32.Lib.
    set GL_INCLUDE_PATH to C:/Program Files/Microsoft Visual Studio 8/VC/PlatformSDK/Include.
    set GL_LIBRARY to C:/Program Files/Microsoft Visual Studio 8/VC/PlatformSDK/Lib/OpenGL32.Lib.

4. Actions before build:

  • In the Visual Studio 2005 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'" inthe left "Solution Explorer" pane, then choose "Build Solution". If you see all 27 projects build succeeded. Then you got a successfull EMAN2 build.

5. Ignore specific library LIBC.lib

If you see this error message, follow the solution.

Problem: LINK : fatal error LNK1104: cannot open file 'LIBC.lib'
Solution: right click project -> Properties -> Linker -> Input -> Ignore Specific Library -> LIBC.lib

6. After compilation

  • change dll to pyd for all EMAN2 python extension libraries:
  • we need copy all the libpyxxx.dll file from EMAN2/bin directory to EMAN2/lib directory. And rename the dll extension to .pyd. Otherwise, we will get an error if we try to import EMAN2 in Python 2.5, "Import Error: no module named libpyxxx".
    ".dll is no longer supported as a filename extension for extension modules. .pyd is now the only filename extension that will searchfor".

7. runtime libraries for EMAN2 GUI program