[hashcash] Difficulty linking to hashcash

  • From: hal@xxxxxxxxxx ("Hal Finney")
  • To: hashcash@xxxxxxxxxxxxx
  • Date: Tue, 4 Jan 2005 22:33:38 -0800 (PST)

I am updating my rpow.net program to use the latest version of hashcash.
I decided to let users download and build hashcash, then my program will
link to the necessary object modules from the hashcash directory to let
my program mint or verify hashcash.

I have two problems.  The first is that although hashcash is structured
to allow it, the hashcash makefile does not build a library of the
object modules.  This means that I have to explicitly list all of the
required hashcash object files in my makefile.  It looks like this:

HCOBJS = $(HCDIR)/libhc.o $(HCDIR)/sdb.o $(HCDIR)/lock.o $(HCDIR)/libsha1.o \
        $(HCDIR)/utct.o $(HCDIR)/random.o $(HCDIR)/sstring.o \
        $(HCDIR)/libfastmint.o $(HCDIR)/fastmint_mmx_standard_1.o \
        $(HCDIR)/fastmint_mmx_compact_1.o $(HCDIR)/fastmint_ansi_compact_1.o \
        $(HCDIR)/fastmint_ansi_standard_1.o \
        $(HCDIR)/fastmint_ansi_compact_2.o \
        $(HCDIR)/fastmint_ansi_standard_2.o \
        $(HCDIR)/fastmint_altivec_standard_1.o \
        $(HCDIR)/fastmint_altivec_standard_2.o \
        $(HCDIR)/fastmint_altivec_compact_2.o \
        $(HCDIR)/fastmint_ansi_ultracompact_1.o $(HCDIR)/fastmint_library.o

The second problem is that I do some bignum calculations, so I also link
to libcrypto.a, the OpenSSL crypto library which is widely available on
Linux systems.  This causes duplicate symbol errors at link time with
the SHA1 functions: SHA1_Init etc.  These same names are used in OpenSSL.

I tried eliminating hashcash's libsha1.o file from my link, which
eliminated the duplicate symbol errors.  However, this means that the
OpenSSL SHA1 code is being used instead, and I think it has a different
SHA1_ctx definition, or some other incompatibility.  I get a bus error
in the hashcash code during minting.

At this point my solution is that people would have to download hashcash,
then I will have them patch it to rename the colliding SHA1 functions.
Then they will build hashcash, and finally build my program.  I'd like
to avoid that patching step if possible, but it would require hashcash
to choose a different name for the SHA1 functions.  Or perhaps there is
some other trick to fix this.


Hal Finney

Other related posts: