WFDB quick start for MS-Windows

The Cygwin project released their first versions of 64-bit Cygwin in July 2013, and these have not been extensively tested. We have not tested them ourselves, and we welcome feedback from users. The instructions below have been used successfully with 32-bit Cygwin by thousands of users, and with 64-bit Cygwin by (so far) one user (thank you!).

On both 32-bit and 64-bit Windows platforms, WAVE (an interactive waveform and annotation viewer and editor) requires DLLs that are available only with 32-bit Cygwin. If you want WAVE, install 32-bit Cygwin and the binary or source versions of the WFDB Software Package.

Precompiled binaries are available for 32-bit Cygwin only. If you do not wish to compile the WFDB Software Package from sources, install 32-bit Cygwin (which can be used on 32-bit or 64-bit versions of Windows). If you want 64-bit binaries, install 64-bit Cygwin and compile the package from sources.

Under Windows Vista or later, it may be necessary to perform some or all of the steps below while logged into an account with "administrator" permissions.

  1. Install 32-bit Cygwin (or 64-bit Cygwin if WAVE is not required), (version 1.7 or later) in a location that does not have any spaces in its pathname. The default and preferred location is c:\cygwin. Do not use locations under Program Files, Documents and Settings, or any other directory containing a space in its name. Be sure to select and install the curl, cygutils-extra, diffutils, gcc, gv, libX11-devel, libcurl-devel, libexpat-devel, make, and openssl-devel packages (these are not installed by default in a minimal Cygwin installation). If you are installing 32-bit Cygwin, also install the sunrpc, xview-devel, and X-start-menu-icons packages (which are not available for 64-bit Cygwin).

    If you are updating a previous installation of the WFDB Software Package, we recommend updating your Cygwin installation first, using Cygwin's setup-x86 or setup-x86_64 tool.

    Since 32-bit Cygwin 1.7 now includes working XView packages, it is no longer necessary (or recommended) to install them separately. Thanks to Ben McClelland for this news.

  2. Open a Cygwin terminal window, and leave it open for the remainder of the steps below. To open a Cygwin window, either click on the Cygwin desktop icon, or find and run c:\cygwin\cygwin.bat. Under Vista or Windows 7, right-click on the Cygwin icon and choose "Run as administrator" (thanks to Albert Titus for this tip). Perform the remainder of the installation by typing the commands as shown below into this Cygwin window. Do not use an MS-DOS window for this purpose.

  3. Download and install the WFDB software package. You may install a set of precompiled binaries, or you may download the sources, compile a set of binaries, and install them. Binary packages are provided as a convenience and may not be up-to-date; we strongly recommend following the simple procedure described below for compiling the software from the sources instead. If you plan to compile WFDB applications that are not included in the binary package, please start with the sources, and read the note below.

    To install the precompiled binaries, type (or copy-and-paste) this two-line command into the Cygwin terminal window:

    curl http://physionet.org/physiotools/binaries/windows/wfdb-CYGWIN.tar.gz | \
      tar xvz -C /usr --strip-components=2
    
    Note that the '\' at the end of the first line indicates that the command continues on the next line. The command will not begin to run until you have entered both lines.

    To download the sources, compile a set of binaries, and install them:

    1. Download and unpack the archive of sources by typing this command:
      curl http://physionet.org/physiotools/wfdb.tar.gz | tar xvz
      
      This creates a directory with a name of the form wfdb-10.m.n within your working directory. Look at the list of files printed by the command above to determine the name of the directory for the next step.
    2. Enter this directory and configure the package:
      cd wfdb-10.m.n
      ./configure
      
      (In the cd command, replace wfdb-10.m.n with the name of the directory as printed by the previous command.)
    3. Compile and install the package:
      make install
      
      The binaries will be installed in /usr/bin (accessible from outside the Cygwin environment as c:\cygwin\usr\bin). Be sure that this bin directory is in your PATH.
    4. (Optional) Check that the WFDB library and applications have been correctly compiled and installed:
      make check
      
      This step compiles a short program that exercises the WFDB library, prints a summary of test results, and prompts you to press <Enter>. After you have done so, the WFDB applications are tested. The tests are very short (typically less than a second each), except that the last one (xform using NETFILES) may take up to a minute if you have a slow or inoperative Internet connection. If any application test fails, its output can be found in the checkpkg subdirectory of the WFDB source tree; compare this output with the files of the same names that can be found in the checkpkg/expected subdirectory.
    5. Make the WFDB library available for other applications:
      ln -sf /usr/bin/libwfdb.dll.a /usr/lib
      

  4. Unless you installed 64-bit Cygwin, test WAVE by starting the Cygwin X server and then running (in an xterm window, such as the one that opens when you start the X server) the command:
    wave -r mitdb/200 -a atr
    

    Note that WAVE's menus (marked with a nabla) are opened using a right click. Annotation editing requires the use of the middle button; if your mouse has only two buttons, you may be able to simulate a middle button click by "chording" (press both buttons at the same time, then release them; see this note for details if necessary).

    If you have not used WAVE before, you may want to follow through the tutorial material in the beginning of the WAVE User's Guide.

  5. Read the manuals. Really! :-) If you want to write your own software to work with PhysioBank data, begin with the WFDB Programmer's Guide. To learn about the wide variety of existing software that can be used to study PhysioBank data, read the WFDB Applications Guide and the WAVE User's Guide.

Using Cygwin gcc to compile and link your applications with the WFDB library

If you wish to compile your own WFDB applications, or others that are not available in binary format, please begin by compiling and installing the WFDB software package sources, as described above. Once you have done so, copy app/Makefile (a text file contained in the WFDB source package) to the directory that contains the source for the application you wish to compile. Note that app/Makefile is customized based on the installation choices that you make when you run ./configure before compiling the WFDB software package, so it's important to copy the customized version of this file from your copy of the WFDB sources only after running ./configure.

If the application is contained in a single source file (for example, myprogram.c) in the same directory as this customized Makefile, you can compile it and link it with the WFDB library using a command such as

make myprogram
This method is recommended since it can be difficult to construct the proper gcc command line manually. As part of the output of make, you will see the gcc command line it constructs, and you can follow this model for subsequent compilations if you prefer not to use make.

If you need to compile an application contained in several source files, use the command generated by make for a single source file compilation and replace the single source name with those of your multiple source files, separated by spaces. Note that the output file name (the argument of gcc's -o option) should not include the .exe suffix.

The WFDB Software Package also includes wfdb-config, a tiny application that helps to construct gcc command lines without using make. Study the example in wfdb-config(1) to see how to use it.

Making a native Windows version of the WFDB library

The procedure above generates a WFDB library that depends upon Cygwin's POSIX emulation library (cygwin1.dll) to provide a Unix-like operating environment, thus assuring that WFDB applications will behave on MS-Windows as much as possible like they do on other platforms. It is also possible, though not generally recommended, to make a WFDB library that depends only on the native libraries provided with MS-Windows. You might need a native Windows version of the WFDB library if you wish to link it to other code that must also be linked with Windows native libraries.

The method outlined below will allow you to create a Windows native version of the WFDB library that does not depend on Cygwin's POSIX emulation library or any third party libraries other than those provided with MS-Windows, and (optionally) curl, which the WFDB library uses for reading data directly from web servers. It uses MinGW, a minimalist development environment for native MS-Windows libraries and applications.

  1. Install MinGW and MSYS using the automated installer tool (mingw-get-inst, also called the "Graphical User Interface Installer" or the "GUI first time installer tool") following the instructions here. Be sure to select the option to use the latest available packages. Use the default installation directory (c:\mingw), and choose all of the optional components.
  2. Download the most recent curl source tarball from curl.haxx.se. As of June 2013, the most recent version was curl-7.31.0.tar.gz. Save it in your MinGW home directory (by default, c:\MinGW\msys\1.0\home\User).
  3. Download the most recent WFDB source tarball, and save it in your MinGW home directory.
  4. Open a MinGW terminal window by clicking on Start → Programs → MinGW → MinGW Shell. Perform the remaining steps of the installation by typing into this window.
  5. If you would like to compile the WFDB-XML applications, install the expat library (not part of a standard MinGW installation):
    mingw-get install libexpat
    
  6. Unpack the tarballs using these commands:
    tar xfvz curl*.tar.gz
    tar xfvz wfdb.tar.gz
    
    These commands will create two directories, named curl-7.x.y and wfdb-10.m.n, where x, y, m and n will depend on the version numbers of the packages you have downloaded.
  7. Compile and install the curl package first:
         cd curl-7.y.z
         ./configure --prefix=/usr
         make
         make install
    
    The ./configure and make commands may require several minutes each.
  8. Compile and install the WFDB Software Package after installing curl:
         cd ../wfdb-10.m.n
         ./configure --prefix=/usr
         make
         make install
    

Notes:

  1. The native Windows libraries created by this procedure are installed in c:\MinGW\msys\1.0\usr\bin; their names are libcurl-4.dll and wfdb-10.5.dll.
  2. A mostly complete set of WFDB applications (except for WAVE) is also installed in the same directory. Use them at your own risk, since they may not behave in exactly the same way as the standard versions of the same applications. You can test the compiled WFDB library and applications using
    make check
    
    (either before or after make install). A handful of the tests performed by make check will fail because they generate text files with MSDOS-style line terminators that don't match the POSIX-style line terminators that make check expects; this is normal and is not an indication of problems.
  3. Copy the libraries and applications to a directory in your Windows PATH if you want to run them using cmd.exe (as, for example, in a DOS box). Avoid installing them in any location that has a space in its pathname.
  4. If you don't want your compiled WFDB library to be able to read data via HTTP, you can skip steps 2 and 6 above, and add --without-netfiles to the configure command in step 7.
  5. You may optionally install OpenSSL before configuring and compiling curl (step 6) if you wish to use the compiled library or applications to read data via HTTPS (for example, directly from your PhysioNetWorks projects). OpenSSL is not required by WFDB applications for reading data from local files or from web servers via HTTP. See the curl web site for details on OpenSSL and other optional libraries.

Using a compiler other than gcc

The procedure in the previous section uses MinGW's gcc to produce WFDB and curl DLLs in Windows native format. You can use any other compiler that is compatible with Windows DLLs to compile application code and link it to these WFDB and curl DLLs, and to other third-party DLLs if you wish.

It is not possible to compile or use WAVE under MS-Windows except by using Cygwin gcc and the Cygwin X11 and XView libraries.

Compiling the WFDB library with a compiler other than gcc is unsupported. gcc is free, is of very high quality, and is supported; if you use another compiler, you are on your own. Your feedback is welcome, but we do not use any commercial compilers and cannot help you learn how to use them.

If you do not use gcc, you must do one of the following:

If you do neither of these steps, your compiler will generate a defective WFDB DLL that assumes that files are always opened in so-called text mode, resulting in errors when reading and writing signal and annotation files (which are binary files). You can check to see if this has happened by running the command

    rdsamp -r 100s

which should yield 21600 numbered lines of output, ending with

     21596	  982	  995
     21597	  978	  989
     21598	  975	  988
     21599	  975	  989

If the output ends after 940 lines, you have a defective WFDB DLL and you will need to follow the instructions above to correct the problem.