User Tools

Site Tools


howto:compile_on_windows_with_cygwin

This is an old revision of the document!


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.Acquisition 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 Cygwin command:

tar -xvf cp2k-2.x.x.tar.bz2

3.Compilation with Cygwin

An ARCH file (a definition file) for Cygwin is as follows:

CC       = cc
CPP      = 
FC       = gfortran
LD       = gfortran
AR       = ar -r
CPPFLAGS = 
DFLAGS   = -D__FFTSG
FCFLAGS  = -O2 -ffast-math -funroll-loops -ftree-vectorize -ffree-form $(DFLAGS) 
LDFLAGS  = $(FCFLAGS) 
LIBS     =  -llapack -lblas

Save as “Cygwin-i686-gfortran.sopt” on cp2k-2.x.x/arch directory as similar to other ARCH files.
Launch the Cygwin Terminal (Cygwin bash) and change the working directory to cp2k-2.x.x/makefiles directory. 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 find cp2k.sopt in cp2k-2.x.x/exe directory, the compilation is successfully done.

4.Installation CP2K on Windows PC which not installed Cygwin

By using either cygcheck command or an executable parser such as Dependency Walker (depends.exe), you can find DLLs where the built cp2k.sopt depends on.
The following six DLLs are maybe necessary and sufficient 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 cp2k.sopt directory.(Consequently these DLLs and cp2k.sopt are located on a same directory.)
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 got a hold of CP2K run on Windows.

howto/compile_on_windows_with_cygwin.1557561522.txt.gz · Last modified: 2020/08/21 10:15 (external edit)