Difference between revisions of "Compiling on Windows"

From Avogadro - Free cross-platform molecule editor
Jump to: navigation, search
m
 
(One intermediate revision by one other user not shown)
Line 1: Line 1:
 
These instructions are to allow users to build Avogadro from the very latest code. Be aware that Avogadro may fail to build or work properly at any given time when built from the instructions below.  
 
These instructions are to allow users to build Avogadro from the very latest code. Be aware that Avogadro may fail to build or work properly at any given time when built from the instructions below.  
  
;Compiling Avogadro for Windows is a complex task and it is recommended that you download the pre-made installer found on the download page. For the adventurous, here are Windows Visual Studio 2008 instructions that may or may not work. For various steps in the process, there may be downloadable binaries on the web. However, for completeness we build all dependencies.
+
;Compiling Avogadro for Windows is a complex task and it is recommended that you download the pre-made installer found on the download page. For the adventurous, here are Windows Visual Studio 2008/2010 instructions that may or may not work. For various steps in the process, there may be downloadable binaries on the web. However, for completeness we build all dependencies.
 
There are also [[Compiling_on_Linux_and_Mac_OS_X|instructions for Linux and Mac OS X]] available.
 
  
= DebugView =
+
* [[Compiling_on_Windows_with_MSVC_2008]]
 +
* [[Compiling_on_Windows_with_MSVC_2010]]
  
[http://technet.microsoft.com/en-us/sysinternals/bb896647.aspx DebugView] is a small program that allows you to view qDebug() output.
+
There are also [[Compiling_on_Linux_and_Mac_OS_X|instructions for Linux and Mac OS X]] available.
 
 
= Windows Visual Studio 2008 (Express) =
 
 
 
NOTE: The redistributable manifest and the version Avogadro compile against do not match. This means that the redistributable's manifest must be altered in order to successfully use the redistributable DLLs. Go to "C:\Program Files\Microsoft Visual Studio 9.0\VC\redist\x86\Microsoft.VC90.CRT" and edit the file called "Microsoft.VC90.CRT.manifest". I used the version string,
 
 
 
<pre>version="9.0.21022.8"</pre>
 
 
 
After I changed that then the DLLs were successfully loaded and the mysterious error message stopped popping up. This was with the standard "free" version downloaded in January 2009.
 
 
== Dependencies ==
 
 
 
Required:
 
;[http://www.cmake.org CMake] (>=2.6.0)
 
;[[#Building Qt4|Qt4]] (>=4.4.0)
 
;[[#Building Eigen 2|Eigen]]
 
;[[#Building OpenBabel 2|OpenBabel]]
 
 
 
For optional OpenGL shader support:
 
;[http://glew.sourceforge.net/ GLEW]
 
 
 
For the optional Python console/bindings:
 
;[http://www.riverbankcomputing.co.uk/software/pyqt/download PyQt4]
 
;[http://www.riverbankcomputing.co.uk/software/sip/download SIP]
 
;[http://www.boostpro.com/products/free Boost libraries] (tested with >=1.36.0, older versions likely work fine)
 
;[http://www.boost.org/users/download/ Boost]
 
 
 
=== Building Qt4 (required) ===
 
 
 
The instructions below are based on [http://wiki.qtcentre.org/index.php?title=Qt4_with_Visual_Studio Qt4 with Visual Studio]. Extract and build Qt4 in the <nowiki>C:\src\qt-<version></nowiki> directory (e.g. <nowiki>C:\src\qt-4.7.2</nowiki> for version 4.5.1).
 
 
 
Compiling Qt takes some time and can require +10GB free disk space. Below are some options to run configure.exe that reduce compile time and disk space requirements.
 
 
-release or -debug : default is -debug-and-release which takes more disk spcace.
 
Unused (by Avogadro) Qt components:
 
-no-webkit
 
-no-phonon
 
-no-phonon-backend
 
-no-qt3support
 
 
 
A full compile & installation could look like (in command prompt):
 
 
 
cd c:\src\qt-7.2
 
configure.exe -opensource -no-webkit -release
 
...
 
Do you accept the terms of the license?
 
y
 
nmake
 
nmake install
 
 
 
* Add <nowiki>C:\src\qt-4.7.2\lib</nowiki> to your PATH. (Control Panel->System->Advanced Tab->Environment Variables)
 
* Make sure qmake.exe is somewhere in your PATH (needed to build PyQt)
 
 
 
=== Building Eigen (required) ===
 
 
 
Download [http://eigen.tuxfamily.org Eigen 2 here]. There is no need to build Eigen since it's a template library consisting of headers only. We simply extract the files to <nowiki>C:\src\eigen-2.0.1</nowiki>. You should now have the Eigen headers in <nowiki>C:\src\eigen-2.0.1\Eigen</nowiki>
 
 
 
=== Building OpenBabel (required) ===
 
 
 
==== zlib 1.2.3 (old version, MSVC 2008) ====
 
 
 
* Download [http://www.winimage.com/zLibDll/ zetlib123.zip here]
 
* Extract to C:\src\zlib-1.2.3
 
* Open C:\src\zlib-1.2.3\projects\visualc6\zlib.sln ('''note:''' This will convert the VC6.0 solution...)
 
* Select the '''DLL Release''' configuration
 
* Build (F7)
 
 
 
The zlib library files are now in C:\src\zlib-1.2.3\projects\visualc6\Win32_DLL_Release. The zlib.h header file is in <nowiki>C:\src\zlib-1.2.3</nowiki>.
 
 
 
==== zlib 1.2.5 (recommended, MSVC 2010) ====
 
 
 
* Download [http://www.winimage.com/zLibDll/ zlib-1.2.5.zip here]
 
* Extract to C:\src\zlib-1.2.5
 
* In the command prompt:
 
cd c:\src\zlib-1.2.5
 
mkdir build
 
cd build
 
del ..\zconf.h
 
cmake -DCMAKE_BUILD_TYPE=Release ..
 
nmake
 
copy zconf.h ..
 
 
 
The zlib library files are now in C:\src\zlib-1.2.5\build. The zlib.h header file is in <nowiki>C:\src\zlib-1.2.5</nowiki>.
 
 
 
==== libxml2 2.7.3 (old version, MSVC 2008) ====
 
 
 
* Download [ftp://xmlsoft.org/libxml2/ libxml2-sources-2.7.3.tar.gz here]
 
* Extract to C:\src\libxml2-2.7.3
 
* In command prompt:
 
*: cd c:\src\libxml2-2.7.3\win32
 
*: cscript configure.js compiler=msvc prefix=c:\local\libxml2 iconv=no zlib=yes include=c:\src\zlib-1.2.3 lib=c:\src\zlib-1.2.3\projects\visualc6\Win32_DLL_Release
 
* Edit Makefile.msvc: change "zdll.lib" to "zlib1.lib"
 
* In command prompt again:
 
*: nmake /f Makefile.msvc
 
*: nmake /f Makefile.msvc install
 
 
 
==== libxml2 2.7.7 (recommended, MSVC 2010) ====
 
 
 
* Download [ftp://xmlsoft.org/libxml2/ libxml2-sources-2.7.7.tar.gz here]
 
* Extract to C:\src\libxml2-2.7.7
 
* In command prompt:
 
cd c:\src\libxml2-2.7.7\win32
 
cscript configure.js compiler=msvc prefix=c:\src\libxml2 iconv=no zlib=yes include=c:\src\zlib-1.2.5 lib=c:\src\zlib-1.2.5\build
 
* Edit Makefile.msvc
 
** line 75: remove /OPT:NOWIN98
 
** line 94: change "zdll.lib" to "zlib.lib"
 
* In command prompt again:
 
nmake /f Makefile.msvc
 
nmake /f Makefile.msvc install
 
 
 
=== boost libraries (recommended) ===
 
 
 
Although boost is an optional dependency for OpenBabel, it is recommended to compile with boost. OpenBabel only needs headers from the boost libraries and extracting the source package to <nowiki>C:\src</nowiki> is enough for now. If you intend to build Avogadro with python support you need build boost python later (see below).
 
 
 
==== Running cmake ====
 
 
 
Download openbabel 2.3.0 if you haven't already and extract it to <nowiki>C:\src</nowiki>
 
 
 
===== Using the Visual Studio 2008 Command Prompt =====
 
 
 
Since we are using cmake 2.6, the installed [http://www.boostpro.com/products/free boost libraries] will be found automatically. If you downloaded the boost source, make sure to also set Boost_INCLUDE_DIR. OpenBabel only uses headers from boost, there is no need to compile any boost libraries before building OpenBabel.
 
 
 
cd c:\openbabel
 
mkdir build
 
cd build
 
cmake -DCMAKE_BUILD_TYPE="Release" -DZLIB_INCLUDE_DIR=c:\openbabel\include -DZLIB_LIBRARY=c:\openbabel\windows-vc2005\zlib1.lib
 
-DLIBXML2_INCLUDE_DIR=c:\openbabel\include -DLIBXML2_LIBRARIES=c:\openbabel\windows-vc2005\libxml2.lib
 
-DLIBRARY_OUPUT_PATH=c:\openbabel\output -DEXECUTABLE_OUPUT_PATH=c:\openbabel\output -G "Visual Studio 9 2008" ..
 
 
 
===== Using the CMake graphical user interface =====
 
 
 
[[Image:Cmake.jpg|thumb|openbabel CMake 2.6 setting for windows]]
 
 
 
# Open the CMake GUI: Start > All programs > CMake 2.6 > cmake-gui(beta)
 
# Set the "Where is the source code" field to <nowiki>C:/openbabel</nowiki>
 
# Set the "Where to build the binaries" field to <nowiki>C:/openbabel/build</nowiki>
 
# Press the "Configure" button
 
# A new dialog will appear where you can select the build environment: Visual Studio 9 2008
 
# Set the combo box (on the right of the search field) to "Grouped View"
 
# Edit the ZLIB and LIBXML2 fields so they resemble the screenshot
 
 
 
==== Building ====
 
 
 
# Open the <nowiki>C:\openbabel\build\openbabel.sln</nowiki> solution
 
# Select the '''Release''' solution configuration.
 
# Build the Solution (F7)
 
 
 
You should now have all files files in <nowiki>C:\openbabel\output\Release</nowiki>.
 
 
 
== Building Avogadro ==
 
 
 
For a minimal build (no python & GLSL shaders), you can now proceed to build Avogadro. If you want python and/or GLSL shader support, build these dependencies first and come back to this step later.
 
 
 
Download Avogadro [http://github.com/cryos/avogadro/zipball/master trunk] or [http://github.com/cryos/avogadro/doawnloads a stable version] and uncompress it to the <nowiki>C:\src\avogadro</nowiki> directory.
 
 
 
* Edit the scripts\cmake-msvc2008.bat file to make sure all paths are correct.
 
* Open the Visual Studio 2008 Command Prompt.
 
cd C:\src\avogadro
 
mkdir build
 
cd build
 
..\scripts\cmake-msvc2008.bat
 
nmake
 
 
 
== Running Avogadro & Building the Installer ==
 
 
 
The easiest way to run avogadro is to build a binary zip file or [http://nsis.sourceforge.net NSIS installer].
 
 
 
If you have set the CPACK_BINARY_ZIP or CPACK_BINARY_NSIS variable when running cmake (see scripts/cmake-msvc2008.bat), all you have to do is:
 
 
 
* In command prompt:
 
nmake PACKAGE
 
 
 
This will generate a zip file or .exe installer in your build dir. Simply extract or install and run avogadro.exe.
 
 
 
== GLSL Shader Support (Optional) ==
 
 
 
* GLEW-1.5.1: http://ovh.dl.sourceforge.net/sourceforge/glew/glew-1.5.1-src.zip
 
* Extract to <nowiki>C:\src</nowiki>
 
* Open C:\src\glew\build\vc6\glew.sln ('''note:''' This will convert the VC6.0 solution...)
 
* Select '''Release''' configuration
 
* Build the '''glew_shared''' target
 
 
 
== Python Support (Optional) ==
 
 
 
=== Building Python ===
 
 
 
* Python 2.6.2: http://www.python.org/ftp/python/2.6.2/Python-2.6.2.tar.bz2
 
** Extract to C:\src
 
** Open c:\src\Python-2.6.2\PCbuild\pcbuild.sln ('''note:''' when using VC++ 2008 express, you'll get an error message saying "solution folders" aren't supported. You can safely ignore this.)
 
** Select '''Release'''
 
** Build (F7)
 
** You now have the files in the PCBuild directory
 
** Copy the exe, lib, dll & pyd files to c:\src\Python-2.6.2\libs
 
** Copy C:\src\Python-2.6.2\PC\pyconfig.h to C:\src\Python-2.6.2\Include
 
 
 
Some targets (7 for 2.6.2) fail because they need additional libraries (encryption, sqlite3, ...). This is not a problem since we don't use these parts.
 
 
 
=== Building Boost.Python ===
 
 
 
* bjam precompiled: http://sourceforge.net/project/showfiles.php?group_id=7586&package_id=72941
 
** place bjam.exe in a directory in your PATH (e.g. C:\Windows) ('''note:''' typing PATH at the MSVC command prompt show your current PATH values)
 
* boost libraries (1.38): http://sourceforge.net/project/showfiles.php?group_id=7586&package_id=8041
 
** Extract to C:\src
 
** Edit C:\src\boost_1_38_0\tools\build\v2\user-config.jam
 
** Add (at the end for example):
 
 
 
using python
 
  : 2.6
 
  : C:/src/Python-2.6.2/libs/python # cmd
 
  : C:/src/Python-2.6.2/Include    # include
 
  : C:/src/Python-2.6.2/libs ;      # libraries
 
 
 
In command promt:
 
 
 
cd C:\src\boost_1_38_0
 
mkdir build
 
bjam --build-dir="build" --toolset=msvc --with-python stage
 
 
 
You now have the following files in '''$BOOST_ROOT/stage/lib''':
 
 
 
boost_python-vc90-mt.lib              185kB
 
boost_python-vc90-mt-1_38.dll          210kB
 
boost_python-vc90-mt-1_38.lib          185kB  # same as 1
 
libboost_python-vc90-mt.lib            5173kB
 
libboost_python-vc90-mt-1_38.lib      5173kB # same as 4
 
 
 
Copy the files above to '''$BOOST_ROOT/lib''', the CPack script expects to find them there
 
 
 
=== Building SIP ===
 
 
 
* http://www.riverbankcomputing.co.uk/static/Downloads/sip4/sip-4.7.9.zip
 
** Extract to C:\src
 
 
 
In command prompt:
 
 
 
cd c:\src\sip-4.7.9
 
C:\src\Python-2.6.2\libs\python.exe configure.py
 
nmake
 
 
 
You now have these files:
 
 
 
C:\src\sip-4.7.9\sipconfig.py
 
C:\src\sip-4.7.9\siplib\sip.h
 
C:\src\sip-4.7.9\siplib\sip.pyd
 
C:\src\sip-4.7.9\siplib\sip.pyd.manifest
 
C:\src\sip-4.7.9\sipgen\sip.exe
 
C:\src\sip-4.7.9\sipgen\sip.exe.manifest
 
 
 
* Copy '''sipconfig.py''', '''sip.pyd''' and '''sip.pyd.manifest''' to <nowiki>C:\src\Python-2.6.2\lib\site-packages\</nowiki>
 
* Copy file '''sip.h''' to <nowiki>C:\src\Python-2.6.2\Include</nowiki>
 
* Copy files '''sip.exe''' and '''sip.exe.manifest''' to <nowiki>C:\src\Python-2.6.2</nowiki>
 
 
 
Notes:
 
* sip.exe[.manifest] is only needed to build PyQt4, no need to include it in the installer
 
* sip.h is also needed to build Avogadro
 
 
 
=== Building PyQt4 ===
 
 
 
Assumes Qt is in C:\Qt\4.4.3, change this if needed...
 
 
 
* PyQt4 4.4.4: http://www.riverbankcomputing.co.uk/static/Downloads/PyQt4/PyQt-win-gpl-4.4.4.zip
 
** Extract to C:\src
 
 
 
In command prompt:
 
 
cd C:\src\PyQt-win-gpl-4.4.4
 
mkdir release
 
copy C:\Qt\4.4.3\lib\QtCore4.dll release\QtCore4.dll
 
C:\src\Python-2.6.2\libs\python.exe configure.py
 
nmake
 
 
 
You now have the .pyd files and their manifests in the Qt* dirs:
 
 
 
C:\src\PyQt-win-gpl-4.4.4\Qt\Qt.pyd(.manifest)
 
C:\src\PyQt-win-gpl-4.4.4\QtCore\QtCore.pyd(.manifest)
 
C:\src\PyQt-win-gpl-4.4.4\QtGui\QtGui.pyd(.manifest)
 
C:\src\PyQt-win-gpl-4.4.4\QtOpenGL\QtOpenGL.pyd(.manifest)
 
...
 
 
 
You can leave the files there, the CPack script will include them in the package.
 
 
 
=== Building numpy ===
 
 
 
* Numpy 1.3.0: http://kent.dl.sourceforge.net/sourceforge/numpy/numpy-1.3.0.tar.gz
 
** Extract to C:\src
 
 
 
In command prompt:
 
 
 
cd c:\src\numpy-1.3.0
 
c:\src\Python-2.6.2\libs\python.exe setup.py install
 
 
 
This will install numpy to the '''C:/src/Python-2.6.2/lib/site-packages''' directory
 
  
numpy/arrayobject.h is in '''C:/src/Python-2.6.2/lib/site-packages/numpy/core/include''' (You'll need this to build Avogadro)
+
[[Category:Developer]]

Latest revision as of 10:17, 19 June 2012

These instructions are to allow users to build Avogadro from the very latest code. Be aware that Avogadro may fail to build or work properly at any given time when built from the instructions below.

Compiling Avogadro for Windows is a complex task and it is recommended that you download the pre-made installer found on the download page. For the adventurous, here are Windows Visual Studio 2008/2010 instructions that may or may not work. For various steps in the process, there may be downloadable binaries on the web. However, for completeness we build all dependencies.

There are also instructions for Linux and Mac OS X available.