Kjetil's Information Center: A Blog About My Projects

Static PDCurses with MinGW

Statically linking a curses program on Windows is not as easy as it sounds. The main problem is that the PDCurses distributions that you'll find on sourceforge.net only contains the dynamic (DLL) library, not the static library. To get the static library, the only option seems to be to build PDCurses yourself from source.

I will try to explain. Before starting, make sure that you have installed MinGW and remembered to include the "make" program as well. Then proceed to download the PDCurses source and unpack it. Open a Windows command window and build it like this:

PATH=C:\MinGW\bin;C:\MinGW\msys\1.0\bin
cd PDCurses-3.4\win32\
make -f mingwin32.mak
          

(I had to set the PATH manually, or else I kept getting problems with a missing reference to libgmp-10.dll.)

The quick and dirty way to now link your curses program is to just copy the resulting pdcurses.a file (from the win32 directory) and the curses.h file (from the root PDCurses directory) to where you got your source and compile like this:

gcc -o program program.c -I. pdcurses.a
          


You can verify that the program is indeed statically linked by using objdump like this:

objdump -p program.exe
          

There should NOT be any reference to a PDCurses.dll file. If there is, well, then the program is still dynamically linked.

Sure a statically linked program is much larger, but it's much easier to distribute, since I doubt many people have the PDCurses.dll file on their Windows computers.

Topic: Configuration, by Kjetil @ 01/01-2014, Article Link