This is an old revision of the document!
Table of Contents
How to Compile and Install CP2K on Windows with Cygwin
1.Cygwin installation:
Cygwin is a large collection of GNU and Open Source tools which provides functionality similar to a Linux distribution on Windows.
To compile CP2K on Windows, you should install Cygwin in the first place if it is not installed on your Windows PC.
For 32 bit Windows execute setup_x86.exe and follow the rest of directions in the wizard.
For 64 bit Windowssetup_x86_64.exe can be used.
When installing Cygwin make sure you install the following additional packages:
- Devel
- “bison”
- “byacc”
- “gcc-fortran”
- “gcc-g++”
- “make”
- Libs
- “lapack”
- “liblapack-devel”
- “liblapack0”
- Python
Please operate according to the wizard to finish the Cygwin installation.
2.Acquiring the code
Visit sourceforge CP2K project page and download any of cp2k-2.x.x.tar.bz2
.
Some archivers generate PaxHeaders.xxxx
directories in cp2k-2.x.x
directory when unpacking. Files in these directories may prevent CP2K compilation with Cygwin, it is recommended to unpack tar.bz2 by using the following command from within a Cygwin terminal:
tar -xvf cp2k-2.x.x.tar.bz2
3.Compilation with Cygwin
An example CP2K ARCH file for a serial build of CP2K on Cygwin is as follows:
CC = cc CPP = FC = gfortran LD = gfortran AR = ar -r CPPFLAGS = DFLAGS = -D__GFORTRAN -D__FFTSG FCFLAGS = -g -O2 -ffast-math -funroll-loops -ftree-vectorize -march=native -ffree-form $(DFLAGS) LDFLAGS = $(FCFLAGS) LIBS = -llapack -lblas OBJECTS_ARCHITECTURE = machine_gfortran.o
Remove the -D__GFORTRAN flag if you compile CP2K 2.6.0. Save it as Cygwin-i686-gfortran.sopt
in the cp2k-2.x.x/arch
directory alongside the other ARCH files.
Launch the Cygwin Terminal (Cygwin bash) and change the working directory to cp2k-2.x.x/makefiles
. Type make command as follows:
make ARCH=Cygwin-i686-gfortran VERSION=sopt
It may take 1 or 2 hours until a compilation is completed. If you have a multi-core machine you may use e.g. make -j 4
to compile in parallel with 4 tasks.
If you find cp2k.sopt
in cp2k-2.x.x/exe
directory, then compilation is successfully done.
4.Installation CP2K on Windows PC which not installed Cygwin
By using either cygcheck command (cygcheck /home/user/(cp2k directory)/exe/(ARCH directory)/cp2k.sopt) or an executable parser such as Dependency Walker (depends.exe), you can find DLLs that the built cp2k.sopt depends on.
The following six DLLs may be required to run the cp2k.sopt without Cygwin installation, but it may differ on your system.(Windows system modules are unnecessary here)
- cygwin\lib\lapack\cygblas-0.dll
- cygwin\bin\cygwin1.dll
- cygwin\bin\cyggfortran-3.dll
- cygwin\bin\cygquadmath-0.dll
- cygwin\bin\cyggcc_s-1.dll
- cygwin\lib\lapack\cyglapack-0.dll
Copy these DLLs (except Windows system DLLs) to the same directory as cp2k.sopt
.
Pressing SHIFT key right-click cp2k.sopt
directory icon and select “Open Command Window Here” menu.
And you type on the command prompt:
> cp2k.sopt --version
Then you might see:
CP2K version 2.X SVN source code revision svn:XXXXX
Congratulations! You can now run CP2K on Windows.