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

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

CC = cc CPP =

FC = gfortran LD = gfortran

AR = ar -r

CPPFLAGS = DFLAGS = -DGFORTRAN -DFFTSG FCFLAGS = -g -O2 -ffast-math -funroll-loops -ftree-vectorize -march=native -ffree-form $(DFLAGS) LDFLAGS = $(FCFLAGS) LIBS = -llapack -lblas

OBJECTS_ARCHITECTURE = machine_gfortran.o

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.

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