Subject: PDFLib compiled for Cygwin32
From: Samy Alex ZAIMI <[email-masked]>
To: [email-masked], [email-masked], [email-masked]
Date: Tue, 20 Jul 1999 04:12:51 +0000

Hello everyone,
I have successfully compiled PDFLib for the Cygwin32 environment, and I have been able to build both static and dynamic libraries, and a binding with
C, C++ and PERL (not the one from ActiveState).

For those among PDFLib list readers who do not know Cygwin32 :
it is just an Unix emulation environment on top of any Win32 OS (Win9x, WinNT, ...), that provides POSIX compatibility and makes it possible to
compile most Unix utilities for Win32 with really very few changes. Note that PDFLib comes with appropriate config files to allow it to be compiled
within MSVC only. Now it is possible to use another (free) compiler for Win32 OS with the following patch (see below for instructions).

For those among Cygwin list readers who do not know PDFLib :
It is a library that provides support for producing PDF documents (and graphics) on the fly, without using Adobe's distiller nor TeX/PDF tools suite.
Current version is 2.0, and informations can be found at http://www.ifconnection.de/~tm/. It is possible to link this library with C, C++, Perl,
Python, Tcl, cgi, java, vb. The possibility to link with script languages like Perl, Python, Tcl, ... is made possible with the use of an utility
called SWIG (BTW : this one compiles without any change, but is not required since interface files are already provided).

So, first download 'pdflib-2.0.tar.gz', and apply the following patch (should be 441 lines long), then follow further instructions below  :
---(cut)---(cut)---(cut)---(cut)---(cut)---
diff -urN pdflib-2.0.orig/bind/c/Makefile.in pdflib-2.0/bind/c/Makefile.in
--- pdflib-2.0.orig/bind/c/Makefile.in Tue Jun 29 00:34:04 1999
+++ pdflib-2.0/bind/c/Makefile.in Sun Jul 18 05:33:16 1999
@@ -16,7 +16,7 @@
 CC = @CC@
 RM      = @RM@

-CFLAGS = -g -c @DEFS@ @DEFINES@ $(PIC_OPT) -I../../pdflib
+CFLAGS = -c @DEFS@ @DEFINES@ $(PIC_OPT) -I../../pdflib
 LDFLAGS = -L../../pdflib

 .SUFFIXES: .c
@@ -41,10 +41,10 @@
  LD_LIBRARY_PATH=../../pdflib ./pdfclock

 hello$(EXE): hello.$(OBJ) ../../pdflib/$(PDFLIB)
- $(CC) $(LDFLAGS) -o $@ $@.$(OBJ) $(LIBS)
+ $(CC) $(LDFLAGS) -o $@ $< $(LIBS)

 pdfclock$(EXE): pdfclock.$(OBJ) ../../pdflib/$(PDFLIB)
- $(CC) $(LDFLAGS) -o $@ $@.$(OBJ) $(LIBS)
+ $(CC) $(LDFLAGS) -o $@ $< $(LIBS)

 clean:
  -$(RM) $(OBJS)hello$(EXE) pdfclock$(EXE) hello.pdf pdfclock.pdf
diff -urN pdflib-2.0.orig/bind/cpp/Makefile.in pdflib-2.0/bind/cpp/Makefile.in
--- pdflib-2.0.orig/bind/cpp/Makefile.in Tue Jun 29 00:34:14 1999
+++ pdflib-2.0/bind/cpp/Makefile.in Sun Jul 18 05:33:22 1999
@@ -24,7 +24,7 @@
 exec_prefix = @exec_prefix@

 PDFLIB = @PDFLIB@
-CXXFLAGS = -c -g @DEFS@ @CCSHARED@ -I../../pdflib
+CXXFLAGS = -c @DEFS@ @CCSHARED@ -I../../pdflib
 LDFLAGS = -L../../pdflib

 .SUFFIXES: .cpp
@@ -53,10 +53,10 @@
 pdflib.o: pdflib.cpp

 pdfclock$(EXE): pdfclock.o pdflib.o ../../pdflib/$(PDFLIB)
- $(CXX) $(LDFLAGS) -o $@ $@.$(OBJ) pdflib.o $(LIBS)
+ $(CXX) $(LDFLAGS) -o $@ $< pdflib.o $(LIBS)

 hello$(EXE): hello.o pdflib.o ../../pdflib/$(PDFLIB)
- $(CXX) $(LDFLAGS) -o $@ $@.$(OBJ) pdflib.o $(LIBS)
+ $(CXX) $(LDFLAGS) -o $@ $< pdflib.o $(LIBS)

 install:

diff -urN pdflib-2.0.orig/bind/perl/Makefile.PL pdflib-2.0/bind/perl/Makefile.PL
--- pdflib-2.0.orig/bind/perl/Makefile.PL Thu Jan 01 02:00:00 1970
+++ pdflib-2.0/bind/perl/Makefile.PL Sun Jul 18 18:08:56 1999
@@ -0,0 +1,12 @@
+#!/usr/local/bin/perl
+# Makefile for PERL binding with PDFLIB.
+use ExtUtils::MakeMaker;
+WriteMakefile(
+'CCFLAGS' => '-w',
+'DEFINE' => '-DHAVE_LIBTIFF -DHAVE_LIBZ -Dbool=char -DHAS_BOOL -DBUILDING_DLL=1',
+'INC' => '-I../../pdflib -I/usr/local/include',
+'LIBS' => '-L../../pdflib -lpdf2.0 -L/usr/local/lib -ltiff -ljpeg -lz -lm',
+'NAME' => 'pdflib',
+'OBJECT' => 'pdflib_pl.o',
+'OPTIMIZE' => '-O6',
+);
diff -urN pdflib-2.0.orig/bind/perl/Makefile.in pdflib-2.0/bind/perl/Makefile.in
--- pdflib-2.0.orig/bind/perl/Makefile.in Tue Jun 29 00:34:26 1999
+++ pdflib-2.0/bind/perl/Makefile.in Sun Jul 18 15:15:56 1999
@@ -24,7 +24,7 @@
 LDSHARED = @LDSHARED@

 PDFLIB = @PDFLIB@
-PDFLIBLINK = -L../../pdflib @PDFLIBLINK@
+PDFLIBLINK = -L../../pdflib @PDFLIBLINK@ -L@PERLINCLUDE@ -lperl
 CFLAGS = -c @PERLBOOLDEF@ @DEFS@ @CCSHARED@ -I../../pdflib

 .SUFFIXES: .c
@@ -33,7 +33,7 @@
  $(CC) $(CFLAGS) $(DEFINES) $<

 # Language-dependent definitions
-LANG_INCDIR = @PERLINCLUDE@
+LANG_INCDIR = -I@PERLINCLUDE@
 LANG_LIBDIR  = @PERLLIBDIR@
 PERLMODDIR = @PERLMODDIR@
 SWIGFLAGS = -I../../pdflib -perl5 -shadow -d pdflib_pl -stat
diff -urN pdflib-2.0.orig/bind/perl/hello.pl pdflib-2.0/bind/perl/hello.pl
--- pdflib-2.0.orig/bind/perl/hello.pl Wed Jun 30 13:26:52 1999
+++ pdflib-2.0/bind/perl/hello.pl Sun Jul 18 12:45:44 1999
@@ -1,4 +1,4 @@
-#!/usr/bin/perl
+#!/usr/local/bin/perl
 # hello.pl
 # Copyright (C) 1997-99 Thomas Merz. All rights reserved.
 #
diff -urN pdflib-2.0.orig/bind/perl/pdfclock.pl pdflib-2.0/bind/perl/pdfclock.pl
--- pdflib-2.0.orig/bind/perl/pdfclock.pl Wed Jun 30 13:26:52 1999
+++ pdflib-2.0/bind/perl/pdfclock.pl Sun Jul 18 14:34:40 1999
@@ -1,4 +1,4 @@
-#!/usr/bin/perl
+#!/usr/local/bin/perl
 # PDFlib client: pdfclock example in Perl
 # (C) Thomas Merz 1998-99

diff -urN pdflib-2.0.orig/clients/Makefile.in pdflib-2.0/clients/Makefile.in
--- pdflib-2.0.orig/clients/Makefile.in Wed Jun 30 13:26:52 1999
+++ pdflib-2.0/clients/Makefile.in Sun Jul 18 05:25:28 1999
@@ -16,8 +16,8 @@
 CC = @CC@
 RM      = @RM@

-CFLAGS = -g -c @DEFS@ @DEFINES@ $(PIC_OPT) -I../pdflib
-LDFLAGS =
+CFLAGS = -c @DEFS@ @DEFINES@ $(PIC_OPT) -I../pdflib
+LDFLAGS = -s

 .SUFFIXES: .c

@@ -41,13 +41,13 @@
 test: all

 pdfimage$(EXE): pdfimage.$(OBJ) ../pdflib/$(PDFLIB) ../pdflib/pdflib.h
- $(CC) $(LDFLAGS) -o $@ $@.$(OBJ) $(LIBS)
+ $(CC) $(LDFLAGS) -o $@ $< $(LIBS)

 pdfgraph$(EXE): pdfgraph.$(OBJ) ../pdflib/$(PDFLIB) ../pdflib/pdflib.h
- $(CC) $(LDFLAGS) -o $@ $@.$(OBJ) $(LIBS)
+ $(CC) $(LDFLAGS) -o $@ $< $(LIBS)

 text2pdf$(EXE): text2pdf.$(OBJ) ../pdflib/$(PDFLIB) ../pdflib/pdflib.h
- $(CC) $(LDFLAGS) -o $@ $@.$(OBJ) $(LIBS)
+ $(CC) $(LDFLAGS) -o $@ $< $(LIBS)

 clean:
  -$(RM) $(OBJS) pdfimage$(EXE) pdfgraph$(EXE) text2pdf$(EXE)
diff -urN pdflib-2.0.orig/clients/pdfgraph.c pdflib-2.0/clients/pdfgraph.c
--- pdflib-2.0.orig/clients/pdfgraph.c Sat Jun 12 15:15:12 1999
+++ pdflib-2.0/clients/pdfgraph.c Sun Jul 18 05:09:56 1999
@@ -40,6 +40,10 @@
 #include <libc.h> /* for getopt(), optind, optarg */
 #endif

+#ifdef __CYGWIN32__
+#include <getopt.h> /* for getopt(), optind, optarg */
+#endif
+
 #include "pdflib.h"
 #include "p_config.h"

diff -urN pdflib-2.0.orig/clients/pdfimage.c pdflib-2.0/clients/pdfimage.c
--- pdflib-2.0.orig/clients/pdfimage.c Sat Jun 12 15:15:18 1999
+++ pdflib-2.0/clients/pdfimage.c Sun Jul 18 05:08:22 1999
@@ -41,6 +41,10 @@
 #include <libc.h> /* for getopt(), optind, optarg */
 #endif

+#ifdef __CYGWIN32__
+#include <getopt.h> /* for getopt(), optind, optarg */
+#endif
+
 #include "pdflib.h"
 #include "p_config.h"

diff -urN pdflib-2.0.orig/clients/text2pdf.c pdflib-2.0/clients/text2pdf.c
--- pdflib-2.0.orig/clients/text2pdf.c Sat Jun 12 15:15:22 1999
+++ pdflib-2.0/clients/text2pdf.c Sun Jul 18 05:10:02 1999
@@ -40,6 +40,10 @@
 #include <libc.h> /* for getopt(), optind, optarg */
 #endif

+#ifdef __CYGWIN32__
+#include <getopt.h> /* for getopt(), optind, optarg */
+#endif
+
 #include "pdflib.h"
 #include "p_config.h"

diff -urN pdflib-2.0.orig/configure pdflib-2.0/configure
--- pdflib-2.0.orig/configure Wed Jun 30 12:52:34 1999
+++ pdflib-2.0/configure Sun Jul 18 15:15:20 1999
@@ -557,7 +557,7 @@

 VERSION="2.0"

-DEFINES=""
+DEFINES="-U_WIN32 -UWIN32 -U__WIN32__ -U_Windows"

 WITH_CPP=nope
 WITH_JAVA=nope
@@ -720,7 +720,7 @@
   fi
 else
   echo "configure: failed program was:" >&5
-  cat conftest.$ac_ext >&5
+  cat < conftest.$ac_ext >&5
   ac_cv_prog_cc_works=no
 fi
 rm -fr conftest*
@@ -815,7 +815,7 @@
 else
   echo "$ac_err" >&5
   echo "configure: failed program was:" >&5
-  cat conftest.$ac_ext >&5
+  cat < conftest.$ac_ext >&5
   rm -rf conftest*
   CPP="${CC-cc} -E -traditional-cpp"
   cat > conftest.$ac_ext <<EOF
@@ -832,7 +832,7 @@
 else
   echo "$ac_err" >&5
   echo "configure: failed program was:" >&5
-  cat conftest.$ac_ext >&5
+  cat < conftest.$ac_ext >&5
   rm -rf conftest*
   CPP=/lib/cpp
 fi
@@ -907,7 +907,7 @@
   fi
 else
   echo "configure: failed program was:" >&5
-  cat conftest.$ac_ext >&5
+  cat < conftest.$ac_ext >&5
   ac_cv_prog_cxx_works=no
 fi
 rm -fr conftest*
@@ -1070,7 +1070,7 @@

 SHELL="/bin/sh"
-EXE=""
+EXE=".exe"
 OBJ="o"
 AR="ar rc"
 RM="rm -f"
@@ -1101,6 +1101,7 @@
  case $ac_sys_system/$ac_sys_release in
  hp*|HP*) SO=.sl;;
  NeXT/3*|next/3*) SO=.a;; # no shared libs on NeXT 3.3 and less
+ cyg*|CYG*) SO=.dll;;
  *) SO=.so;;
  esac
 fi
@@ -1124,6 +1125,7 @@
  NeXT|next/3*) LDSHARED="ld -u libsys_s";;
  NeXT|next/4*) LDSHARED="cc -nostdlib -r ";;
  SCO_SV*) LDSHARED="ld -G";;
+ cyg*|CYG*) LDSHARED="dllwrap --export-all --driver-name gcc --output-def libpdf$VERSION.def --implib libpdf$VERSION.a ";;
  *) LDSHARED="ld";;
  esac
 fi
@@ -1143,6 +1145,7 @@
  Linux*) CCSHARED="-fpic";;
  SCO_SV*) CCSHARED="-Kpic -belf";;
  FreeBSD*) CCSHARED="-fpic";;
+ cyg*|CYG*) CCSHARED="-DBUILDING_DLL=1";;
  esac
 fi
 echo "$ac_t""$CCSHARED" 1>&6
@@ -1253,7 +1256,7 @@
 else
   echo "$ac_err" >&5
   echo "configure: failed program was:" >&5
-  cat conftest.$ac_ext >&5
+  cat < conftest.$ac_ext >&5
   rm -rf conftest*
   JAVAINCLUDE="nope"
 fi
@@ -1336,7 +1339,7 @@
 else
   echo "$ac_err" >&5
   echo "configure: failed program was:" >&5
-  cat conftest.$ac_ext >&5
+  cat < conftest.$ac_ext >&5
   rm -rf conftest*
   TCLINCLUDE="nope"
 fi
@@ -1554,19 +1557,19 @@
   for i in $dirs; do
    if test -r $i/perl.h; then
     echo "$ac_t""$i" 1>&6
-    PERLINCLUDE="-I$i"
+    PERLINCLUDE="$i"
     break;
    fi
   done
   if test "$PERLINCLUDE" = none; then
-   PERLINCLUDE="-I$PERL5DIR/CORE"
+   PERLINCLUDE="$PERL5DIR/CORE"
    echo "$ac_t""could not locate perl.h...using $PERLINCLUDE" 1>&6
   else
       WITH_PERL=yes
   fi
  else
   echo "$ac_t""unable to determine perl5 configuration" 1>&6
-  PERLINCLUDE="-I$PERL5DIR"
+  PERLINCLUDE="$PERL5DIR"
  fi
  PERLLIBDIR=`($PERL -e 'use Config; print $Config{sitearchexp};') 2>/dev/null`
  if test -z "$PERLLIBDIR" -o ! -d "$PERLLIBDIR"; then
@@ -1580,7 +1583,7 @@
  fi
     else
         echo "$ac_t""could not figure out how to run perl5" 1>&6
- PERLINCLUDE="-I/usr/local/lib/perl/archname/5.005/CORE"
+ PERLINCLUDE="/usr/local/lib/perl/archname/5.005/CORE"
     fi

 # The Perl include files contain special handling for the bool type
@@ -1880,6 +1883,7 @@

 if test "$WITH_STATIC" = "yes" ; then
  PDFLIB=libpdf.a
+ LIBVERSION=""
  # no language bindings without shared libraries
  BINDINGS=""
  BINDINGS_INSTALL=""
@@ -1888,6 +1892,7 @@
  CCSHARED=""
 else
  PDFLIB=libpdf$VERSION$SO
+ LIBVERSION=$VERSION
 fi

@@ -1902,7 +1907,7 @@
     ZLIBLINK=""
 fi

-PDFLIBLINK="-lpdf$VERSION $TIFFLINK $ZLIBLINK -lm"
+PDFLIBLINK="-lpdf$LIBVERSION $TIFFLINK $ZLIBLINK -lm"

@@ -1950,7 +1955,7 @@
 else
   if test -w $cache_file; then
     echo "updating cache $cache_file"
-    cat confcache > $cache_file
+    cat < confcache > $cache_file
   else
     echo "not updating unwritable cache $cache_file"
   fi
@@ -2092,6 +2097,7 @@
 s%@PERLMODDIR@%$PERLMODDIR%g
 s%@PERLBOOLDEF@%$PERLBOOLDEF%g
 s%@TIFFINC@%$TIFFINC%g
+s%@TIFFLINK@%$TIFFLINK%g
 s%@ZLIBINC@%$ZLIBINC%g
 s%@ZLIBLINK@%$ZLIBLINK%g
 s%@BINDINGS@%$BINDINGS%g
diff -urN pdflib-2.0.orig/pdflib/Makefile.in pdflib-2.0/pdflib/Makefile.in
--- pdflib-2.0.orig/pdflib/Makefile.in Wed Jun 30 13:26:52 1999
+++ pdflib-2.0/pdflib/Makefile.in Sun Jul 18 13:50:08 1999
@@ -32,7 +32,7 @@
 # Either pdflib.a or pdflib.so, selected by configure script
 PDFLIB = @PDFLIB@

-CFLAGS = -c -g @DEFS@ @DEFINES@ @CCSHARED@ $(TIFFINC) $(ZLIBINC)
+CFLAGS = -c @DEFS@ @DEFINES@ @CCSHARED@ $(TIFFINC) $(ZLIBINC)

 .SUFFIXES: .c

@@ -84,10 +84,10 @@

 libpdf$(VERSION)$(SO): $(OBJS)
  $(RM) $(PDFLIB)
- $(LDSHARED) -o $(PDFLIB) $(OBJS)
+ $(LDSHARED) -o $(PDFLIB) $(OBJS) @TIFFLINK@ @ZLIBLINK@

 clean:
- -$(RM) $(OBJS) $(PDFLIB)
+ -$(RM) $(OBJS) libpdf@VERSION@.*

 maintainer-clean: clean
  -$(RM) Makefile.in.bak
diff -urN pdflib-2.0.orig/test/Makefile.in pdflib-2.0/test/Makefile.in
--- pdflib-2.0.orig/test/Makefile.in Wed Jun 30 13:26:52 1999
+++ pdflib-2.0/test/Makefile.in Sun Jul 18 05:32:56 1999
@@ -16,7 +16,7 @@
 CC = @CC@
 RM      = @RM@

-CFLAGS = -c -g @DEFS@ @DEFINES@ -I../pdflib
+CFLAGS = -c @DEFS@ @DEFINES@ -I../pdflib
 LDFLAGS =

 .SUFFIXES: .c
@@ -38,7 +38,7 @@
  LD_LIBRARY_PATH=../pdflib ./pdftest

 pdftest$(EXE): $(OBJS) ../pdflib/$(PDFLIB)
- $(CC) $(LDFLAGS) -o $@ $@.$(OBJ) $(LIBS)
+ $(CC) $(LDFLAGS) -o $@ $< $(LIBS)

 clean:
  -$(RM) pdftest$(EXE) pdftest*.pdf $(OBJS)
diff -urN pdflib-2.0.orig/util/Makefile.in pdflib-2.0/util/Makefile.in
--- pdflib-2.0.orig/util/Makefile.in Wed Jun 30 13:26:54 1999
+++ pdflib-2.0/util/Makefile.in Sun Jul 18 05:38:08 1999
@@ -29,7 +29,7 @@

 TIFFINC = @TIFFINC@

-CFLAGS = -c -g @DEFS@ @DEFINES@ -I../pdflib $(TIFFINC)
+CFLAGS = -c @DEFS@ @DEFINES@ -I../pdflib $(TIFFINC)

 .SUFFIXES: .c

@@ -45,7 +45,7 @@
 PROGS = \
  compile_metrics$(EXE)

-all: compile_metrics
+all: $(PROGS)

 clean:
  $(RM) $(OBJS) $(PROGS) Makefile.in.bak
@@ -68,7 +68,7 @@
  $(CC) $(CFLAGS) -MM $(SRC)>>Makefile.in

 compile_metrics$(EXE): compile_metrics.$(OBJ) ../pdflib/$(PDFLIB)
- $(CC) $(LDFLAGS) -o $@ $@.$(OBJ) $(LIBS)
+ $(CC) $(LDFLAGS) -o $@ $< $(LIBS)

 # Automatically generated dependencies
 compile_metrics.o: compile_metrics.c ../pdflib/p_intern.h \
diff -urN pdflib-2.0.orig/util/compile_metrics.c pdflib-2.0/util/compile_metrics.c
--- pdflib-2.0.orig/util/compile_metrics.c Sun Jun 27 12:16:06 1999
+++ pdflib-2.0/util/compile_metrics.c Sun Jul 18 05:11:52 1999
@@ -37,6 +37,10 @@
 #include <libc.h>
 #endif

+#ifdef __CYGWIN32__
+#include <getopt.h>
+#endif
+
 #include "p_intern.h"
 #include "p_afmparse.h"

---(cut)---(cut)---(cut)---(cut)---(cut)---

Done ? Ok, go to the root directory of PDFLib distribution, then type :
    ./configure
for building a dynamic library called 'pdflib2.0.dll', or :
    ./configure --with-static
for building a static library called 'pdflib.a'.
Note that in the latter case only C and C++ bindings are available.
I have tried the dynamic library with C, C++ and Perl5.00503 compiled with dynamic libraries support.
The compilation for Python or Tcl were skipped since I don't have these.

Do 'make' and wait until everything finishes. Then, cd to 'bind/perl' and do
    perl Makefile.PL ; make ; make install
or
    ./Makefile.PL ; make ; make install
The file called 'Makefile.PL' DOES NOT belong to the original distribution and is installed by the patch above.
This action creates a new Makefile that is better suited for local PERL installation, that is a PERL suite which was compiled locally with dynamic
library support.

You can run the tests afterwards, that is change to the root directory then run 'make test'. In the PERL directory, you can do :
    ./hello.pl
and
    ./pdfclock.pl
Similar programs exists in the C and CPP subfolders (and others too, but I didn't try them).
The first one outputs a PDF document that just contains the typical "Hello World" message, and the second one outputs a PDF document that represents
an analog clock indicating the time when the file was created.

Other tests are available under the 'test' subfolder.

Well, I hope you enjoyed it. Any feedback is of course most welcome, but consider the fact that the current Email address might not be reliable after
the end of this month (july 1999). In the meantime, I just would like other people try this patch to see if it works on their environment too.

Bye,
Dr.-Ing. Sami Alex ZAIMI
IAMP - Tohoku University - Sendai (Japan)

--
Want to unsubscribe from this list?
Send a message to [email-masked]