Trouble building PInfo

I am having trouble building Pinfo.

My configure line looks like this:
./configure –prefix=/usr/mylocal –with-curses=/usr/mylocal

The error message I get is
checking location of curses.h file… /usr/mylocal/include/ncurses/ncurses.h
checking if curses is usable… no
configure: error: Curses not found. You need curses to compile pinfo

However, it manages to locate ncurses.h as you can tell from this excerpt from config.log, but then claims the routines are missing. If I try building conftest.c myself with –save-temps and then look at conftest.i, each routine is defined as “extern WINDOW *”, for example “extern WINDOW * stdscr;”. There is also a “typedef struct _win_st WINDOW;” statement to define WINDOW.

configure:9858: checking location of curses.h file
configure:9901: result: /usr/mylocal/include/ncurses/ncurses.h
configure:10142: checking if curses is usable
configure:10171: gcc -o conftest -g -O2 -I/usr/mylocal/include -L/usr/mylocal/lib -lncurses conftest.c >&5
/tmp/ccAGkDPW.o: In function `main’:
/home/myuser/apps/wip/pinfo-0.6.9/conftest.c:37: undefined reference to `initscr’
/home/myuser/apps/wip/pinfo-0.6.9/conftest.c:38: undefined reference to `printw’
/home/myuser/apps/wip/pinfo-0.6.9/conftest.c:39: undefined reference to `stdscr’
/home/myuser/apps/wip/pinfo-0.6.9/conftest.c:39: undefined reference to `wrefresh’
/home/myuser/apps/wip/pinfo-0.6.9/conftest.c:40: undefined reference to `stdscr’
/home/myuser/apps/wip/pinfo-0.6.9/conftest.c:40: undefined reference to `wgetch’
/home/myuser/apps/wip/pinfo-0.6.9/conftest.c:40: undefined reference to `stdscr’
/home/myuser/apps/wip/pinfo-0.6.9/conftest.c:40: undefined reference to `wgetch’
/home/myuser/apps/wip/pinfo-0.6.9/conftest.c:41: undefined reference to `endwin’
collect2: ld returned 1 exit status
configure:10177: $? = 1
configure: failed program was:
| /* confdefs.h. */
| #define PACKAGE_NAME “pinfo”
| #define PACKAGE_TARNAME “pinfo”
| #define PACKAGE_VERSION “0.6.9″
| #define PACKAGE_STRING “pinfo 0.6.9″
| #define PACKAGE “pinfo”
| #define VERSION “0.6.9″
| #define HAVE_STRDUP 1
| #define HAVE_STRSTR 1
| #define HAVE_STRSEP 1
| #define HAVE_GETOPT_LONG 1
| #define HAVE_SNPRINTF 1
| #define HAVE_SIGBLOCK 1
| #define STDC_HEADERS 1
| #define HAVE_SYS_TYPES_H 1
| #define HAVE_SYS_STAT_H 1
| #define HAVE_STDLIB_H 1
| #define HAVE_STRING_H 1
| #define HAVE_MEMORY_H 1
| #define HAVE_STRINGS_H 1
| #define HAVE_INTTYPES_H 1
| #define HAVE_STDINT_H 1
| #define HAVE_UNISTD_H 1
| #define HAVE_DLFCN_H 1
| #define HAS_READLINE 1
| /* end confdefs.h. */
| #include
| int
| main ()
| {
| initscr();
| printw(“Hello World !!!”);
| refresh();
| getch();
| endwin();
| return 0;
| ;
| return 0;
| }
configure:10202: result: no
configure:10546: error: Curses not found. You need curses to compile pinfo

However, all the routines are there when I check /usr/mylocal/include/ncurses/ncurses.h

$ grep -w initscr /usr/mylocal/include/ncurses/ncurses.h
extern NCURSES_EXPORT(WINDOW *) initscr (void); /* implemented */
$ grep -w printw /usr/mylocal/include/ncurses/ncurses.h
extern NCURSES_EXPORT(int) printw (const char *,…) /* implemented */
$ grep -w refresh /usr/mylocal/include/ncurses/ncurses.h
#define _HASMOVED 0×20 /* has cursor moved since last refresh? */
extern NCURSES_EXPORT(int) refresh (void); /* generated */
#define refresh() wrefresh(stdscr)
#define KEY_REFRESH 0565 /* refresh key */
#undef refresh
$ grep -w getch /usr/mylocal/include/ncurses/ncurses.h
extern NCURSES_EXPORT(int) getch (void); /* generated */
#define getch() wgetch(stdscr)
$ grep endwin /usr/mylocal/include/ncurses/ncurses.h
extern NCURSES_EXPORT(int) endwin (void); /* implemented */
extern NCURSES_EXPORT(bool) isendwin (void); /* implemented */

I managed to get it to build using
gcc -o conftest.o conftest.c -I/usr/mylocal/include -g -L/usr/mylocal/lib -lncurses
instead of
gcc -o conftest -g -O2 -I/usr/mylocal/include -L/usr/mylocal/lib -lncurses conftest.c
so lets try
gcc -o conftest conftest.c -g -O2 -I/usr/mylocal/include -L/usr/mylocal/lib -lncurses

Hmm. Looks like it has something to do with the position of the source file in the command which is very strange as the manual says

You can mix options and other arguments. For the most part, the order you use doesn’t matter. Order does matter when you use several options of the same kind; for example, if you specify -L more than once, the directories are searched in the order specified.

So for the time being, I have modified configure so that the definition for ac_link (in 9 places) is now
ac_link=’$CC -o conftest$ac_exeext conftest.$ac_ext $CFLAGS $CPPFLAGS $LDFLAGS $LIBS >&5′

An excellent guide to gcc and other utilities by BRUCE PERENS can be found at

Details of hunt for initscr from ncurses.h

  1. //usr/mylocal/include/ncurses/ncurses.h
  2. extern NCURSES_EXPORT(WINDOW *) initscr (void);                         /* implemented */
  3. NCURSES_EXPORT(int) vsscanf(const char *, const char *, va_list);
  4. #define vsscanf(a,b,c) _nc_vsscanf(a,b,c)
  5. typedef struct _win_st WINDOW;
  7. struct _win_st
  8. {
  9.         NCURSES_SIZE_T _cury, _curx; /* current cursor position */
  11.         /* window location and size */
  12.         NCURSES_SIZE_T _maxy, _maxx; /* maximums of x and y, NOT window size */
  13.         NCURSES_SIZE_T _begy, _begx; /* screen coords of upper-left-hand corner */
  15.         short   _flags;         /* window state flags */
  18.         /* attribute tracking */
  19.         attr_t  _attrs;         /* current attribute for non-space character */
  20.         chtype  _bkgd;          /* current background char/attribute pair */
  22.         /* option values set by user */
  23.         bool    _notimeout;     /* no time out on function-key entry? */
  24.         bool    _clear;         /* consider all data in the window invalid? */
  25.         bool    _leaveok;       /* OK to not reset cursor on exit? */
  26.         bool    _scroll;        /* OK to scroll this window? */
  27.         bool    _idlok;         /* OK to use insert/delete line? */
  28.         bool    _idcok;         /* OK to use insert/delete char? */
  29.         bool    _immed;         /* window in immed mode? (not yet used) */
  30.         bool    _sync;          /* window in sync mode? */
  31.         bool    _use_keypad;    /* process function keys into KEY_ symbols? */
  32.         int     _delay;         /* 0 = nodelay, <0 = blocking, >0 = delay */
  34.         struct ldat *_line;     /* the actual line data */
  36.         /* global screen state */
  37.         NCURSES_SIZE_T _regtop; /* top line of scrolling region */
  38.         NCURSES_SIZE_T _regbottom; /* bottom line of scrolling region */
  40.         /* these are used only if this is a sub-window */
  41.         int     _parx;          /* x coordinate of this window in parent */
  42.         int     _pary;          /* y coordinate of this window in parent */
  43.         WINDOW  *_parent;       /* pointer to parent if a sub-window */
  45.         /* these are used only if this is a pad */
  46.         struct pdat
  47.         {
  48.             NCURSES_SIZE_T _pad_y,      _pa
  49.             NCURSES_SIZE_T _pad_top,    _pad_left;
  50.             NCURSES_SIZE_T _pad_bottom, _pad_right;
  51.         } _pad;
  53.         NCURSES_SIZE_T _yoffset; /* real begy is _begy + _yoffset */
  56.         cchar_t  _bkgrnd;       /* current background char/attribute pair */
  57. #if 0
  58.         int     _color;         /* current color-pair for non-space character */
  59. #endif
  60. #endif
  61. }

Verifying a signed download

Some files have been signed by their author to prove that nobody else has tampered with them. This is particularly true of source code or appllications you have downloaded off the web.

For example the antivirus package clamav can be downloaded from Sourceforge. There will be two files for you to download clamav-x.x.x.tar.gz and clamav-x.x.x.tar.gz.sig. The first file is the source code in a compressed format and the second is the signature for the format. In order to verify the signature, you will need GnuPG or PGP installed on the computer you are going to download the file to. I have given details of how to compile GnuPG elsewhere in this blog.

In order to verify the signature, we use the command gpg –verify clamav-x.x.x.tar.gz.sig

[mylogin][~]$ gpg –verify clamav-x.x.x.tar.gz.sig
gpg: keyring `/home/mylogin/.gnupg/secring.gpg’ created
gpg: keyring `/home/mylogin/.gnupg/pubring.gpg’ created
gpg: Signature made Mon Mar 13 17:44:03 2006 MST using DSA key ID 985A444B
gpg: Can’t check signature: public key not found

The trouble is that we do not have yet the public key for the person who signed the file. We can get this from a public keyserver such as or You will need the key ID printed in the penultimate (last but one) line above. In this case 985A444B.

We should be able to use the command gpg –keyserver –recv-keys 0x985A444B to retrieve the key automatically, but get the error
[mylogin][~]$ gpg –keyserver –recv-keys 0x985A444B
gpg: requesting key 985A444B from hkp server
/usr/mylocal/libexec/gnupg/gpgkeys_hkp: error while loading shared libraries: cannot open shared object file: No such file or directory
gpg: no handler for keyserver scheme `hkp’
gpg: keyserver receive failed: keyserver error

So we downloaded the public key from instead and saved it to the file clamav.key. NOTE: In order to lookup the public key, you will need to add ’0x’ (zero x) to the front of the key ID, so 985A444B becomes 0x985A444B. The public key can be a large file, so copy and paste it rather than trying to type it.
[mylogin][~]$ gpg –import clamav.key
gpg: key 985A444B: public key “Tomasz Kojm ” imported
gpg: Total number processed: 1
gpg: imported: 1
gpg: no ultimately trusted keys found

Once we have added the key to our public keyring, we can verify the signature
[mylogin][~]$ gpg –verify clamav-0.90RC1.1.tar.gz.sig
gpg: Signature made Mon Oct 16 02:56:15 2006 MDT using DSA key ID 985A444B
gpg: Good signature from “Tomasz Kojm
gpg: aka “Tomasz Kojm
gpg: aka “Tomasz Kojm
gpg: WARNING: This key is not certified with a trusted signature!
gpg: There is no indication that the signature belongs to the owner.
Primary key fingerprint: 0DCA 5A08 407D 5288 279D B434 5482 2DC8 985A 444B

Note that we still do not trust this key – we have just proven that the downloaded file has not been tampered with.

Upgrading php


I want to upgrade the installation of php on my server as I feel it is important to keep abreast of the bug fixes in core applications, especially the popular ones which will be subject to the most abuse.

Required packages:

  • gdbm (a set of database routines that use extensible hashing)
  • bison (general-purpose parser generator that converts an annotated context-free grammar into an LALR(1) or GLR parser for that grammar)
  • flex (A fast lexical analyser generator for generating programs that perform pattern-matching on text.)
  • php

Optional packages:

  • For IMAP support:
    • IMAP
    • Kerebos
    • Pinfo
  • For DB3 support:
    • Berrkley DB
    • AOP
  • For Interbase support:
    • Interbase
    • AOP

Building the libraries


The source files for gdbm are available by FTP from the GNU servers. Open a connection to their server and download the latest version (1.8.3 at the time of writing)
# ftp
# login: anonymous password:anon@
# cd gnu/gdbm
# passive
# dir gdbm-*
# get gdbm-1.8.3.tar.gz
# quit

Next we need to unzip the file we have just downloaded and change to the directory
# gunzip -c gdbm-1.8.3.tar.gz|tar x
# cd gdbm-1.8.3

Then we need to run autoconfigure. As we do not have root access, we need to specify an alternative location for the build. I have chosen /usr/mylocal. We will redirect the output to a couple of files so that we do not miss anything.
# ./configure –prefix=/usr/mylocal >log.config 2>err.config

Check that no errors were encountered and fix any that were logged before proceeding further.
#ls -l err.config
#less err.config

Build the package and check for any errors
#make >log.make 2>err.make
#ls -l err.make
#less err.make

Install the gdbm package
#make install>log.install 2>err.install
#ls -l err.install
#less err.install


We need to follow the same procedure to build the bison library.
# ftp
# login: anonymous password:anon@
# cd gnu/bison
# passive
# dir bison-*
# get bison-2.3.tar.bz2
# get bison-2.3.tar.bz2.sig
# quit
# gpg –verify bison-2.3.tar.bz2.sig
# bunzip2 -c bison-2.3.tar.bz2 | tar x
# cd bison-2.3
# ./configure –prefix=/usr/mylocal >log.config 2>err.config
# make >log.make 2>err.make
# make install >log.install 2>err.install


# bunzip2 -c flex-2.5.33.tar.bz2|tar x
# cd flex-2.5.33
# ./configure –prefix=/usr/mylocal >log.config 2>err.config
# make check >log.check 2>err.check
# make >log.make 2>err.make
# make install >log.make 2>err.make

IMAP Support


# ln -s /usr/mylocal/inc/


# wget
# wget
# gpg –verify pinfo-0.6.9.tar.bz2.sig
# bunzip2 -c pinfo-0.6.9.tar.bz2 |tar x
# cd pinfo-0.6.9
# ./configure –prefix=/usr/mylocal –with-curses=/usr/mylocal >log.config 2>err.config
# make >log.make 2>err.make
# make install >log.install 2>err.install



Build php

php requires the header file for gdbm.h to be in one of four locations, so create a link in /usr/local/include. First, however, we need write access rights to the
# chmod u+w /usr/local/include
# ln -s /usr/mylocal/include/gdbm.h /usr/local/include/gdbm.h
# chmod u-w /usr/local/include

Download the latest source from directly to your server:directory.

  • wget

Extract the source files using the command gunzip – c php-4.x.x.tar.gz|tar x and then change into the directory you have just created (cd php-4.x.x)

If you already have php installed (as I do), then create a file called phpinfo.php and place it in your webserver’s home directory so that you can run it. It should contain the following code:

  1. <?php
  2. phpinfo();
  3. ?>

When you run this code, it will display the current configuration for your version of php. Copy it for this new build and add the bits in bold. Your configuration command should look something like this and needs to be on one line:

./configure –prefix=/usr/mylocal –with-apxs=/usr/sbin/apxs –with-gd –with-jpeg-dir=/usr/lib –with-gettext=/usr –enable-safe-mode –with-config-file-path=/etc/httpd –with-exec-dir=/usr/bin –with-zlib –enable-magic-quotes –with-regex=system –with-ttf –with-db –with-gdbm –enable-mbstring –enable-mbstr-enc-trans –enable-track-vars –enable-wddx=shared –enable-mm=shared –enable-xml –enable-ftp –disable-debug –with-libdir=/usr/lib –with-db3 –with-interbase=shared –with-pgsql=shared –with-ldap –with-imap –with-pdflib=shared –enable-sockets >log.config 2>err.config

If you get the error configure: error: no acceptable cc found in $PATH, then you do not have a compiler installed. Try something like GCC

error: Cannot find rfc822.h.
Possible SOLUTION: Download and build latest imap.tar.Z from and Kerebos from

The following options are causing problems:
–with-gettext=/usr –with-exec-dir=/usr/bin –with-libdir=/usr/lib

error: Header contains different version
Possible SOLUTION: Missing header files. Download and install BerkleyDB from Current version is 4.5.20, so download is wget

Alternative location (for db3)

error: libgds or libib_util not found!
Possible SOLUTION: Download interbase 6.01 from

–with-pdflib=shared –with-jpeg-dir=/usr/lib –with-zlib
PDFlib extension requires at least pdflib 3.x. You may also need libtiff, libjpeg, libpng and libz. Use the options –with-tiff-dir=<DIR>, –with-jpeg-dir=<DIR>, –with-png-dir=<DIR> and –with-zlib-dir=<DIR>
Possible SOLUTION: Download PDFLite (for private use) or purchase license from PDFLib
which leaves
./configure –prefix=/usr/mylocal –with-apxs=/usr/sbin/apxs –with-gd –enable-safe-mode –with-config-file-path=/etc/httpd –enable-magic-quotes –with-regex=system –with-ttf –with-db –with-gdbm –enable-mbstring –enable-mbstr-enc-trans –enable-track-vars –enable-wddx=shared –enable-mm=shared –enable-xml –enable-ftp –disable-debug –with-pgsql=shared –with-ldap –enable-sockets –with-mysql=/usr/local/mysql

then type:


If you get the error make: *** No targets specified and no makefile found. Stop., then configure did not work properly. Go back and check log.config for the problem. If configure worked properly, then it should contain the following sections:

  • Configuring SAPI modules
  • Running system checks
  • General settings
  • Configuring extensions
  • Configuring PEAR
  • Configuring Zend
  • Configuring TSRM
  • Configuring libtool
  • Generating files
  • before ending with

  • Thank you for using PHP.

and then:

make install

backup your php.ini file:

cp php.ini.bak /etc/httpd/php.ini

you will need to edit your php.ini file now:

pico -w /etc/httpd/php.ini

register_globals = Off

change to
register_globals = On

PHP tends to make some changes to your httpd.conf file so you may need too edit it:

pico -w /etc/httpd/conf/httpd.conf

add this line:

LoadModule php4_module /usr/lib/apache/

put it in the #Extra Modules area of the file.

save your changes and now just one more file too edit:

pico -w /etc/httpd/conf/srm.conf

add this line:

AddType application/x-httpd-php .php .php4 .phtml

save your changes, then stop and start httpd:

/etc/rc.d/init.d/httpd restart

(i know this seems similar to other tuts but i learnt from other tuts around this forum and other forums so my way of installing is similar)

This works i have tested it on my machine here at work.

If you get the error configure: error: png.h not found. when you try make install, then install LibPNG

The instructions above suggest including “–with-imap” in the configure line. This was a major problem on my RaQ 550, although I really wanted IMAP support. The error messages in config.log were:

configure:40552: checking whether IMAP works
configure:40585: gcc -o conftest -g -O2 -Wl,-rpath,/usr/local/lib -L/usr/local/lib conftest.c -lc-client -lssl -lcrypto -lcrypt -lpam -lttf -lpng -lz -lz -lgdbm -lz -lssl -lcrypto -lresolv -lm -ldl -lnsl -lxml2 -lz -lm 1>&5
/usr/lib/libc-client.a(mail.o): In function `mm_cache’:
/usr/src/redhat/BUILD/imap-2002d/c-client/mail.c:203: undefined reference to `__canary_death_handler’

Temporarily moving the (non-stackguard) GCC compiler, and linking the StackGuard version of GCC to the default location makes it work.

# mv /usr/bin/gcc /usr/bin/gcc.bak
# ln -s /usr/sg/bin/gcc /usr/bin/gcc

Now head over to your PHP source folder and do a standard configuration..

# cd php-4.3.4
# ./configure –configure-options

… finish building PHP, and be sure to move the original GCC back into place when you are done.

# mv /usr/bin/gcc.bak /usr/bin/gcc