Next Previous Table of Contents

Installation

There are a number of ways to install this library: Note that if you use the C linkable functions you are on your own for testing right now, although the C++ programs in the tests directory should help.

Making the C Linkable Functions Only for GCC Using the Pregenerated Files

  1. The pregenerated assembly files for gcc are in the directory pregen/gnu.
  2. Each of these files includes the file asm.h which contains some macros that the C preprocessor can use to convert the *.S files into raw assembly suitable for your local setup. asm.h is in the pregen/h directory.
  3. pregen/h/clink.h provides a header file to link the assembly functions with C or C++ code.

Making the C Linkable Functions Only for MSVC++ Using the Pregenerated Files

  1. The pregenerated C files containing inline assembly code for MSVC++ are in the directory pregen/masm_inl/fastcall.
  2. The file pregen/h/clink.h is a header file that that can be used when linking these C functions with C or C++ code.

Making the C Linkable Functions Only for Watcom Using the Pregenerated Files

  1. The pregenerated assembly files for WASM to translate into object files are in the directory pregen/watcom/register if you would like to use register calling conventions and in pregen/watcom/stack if you would like to use stack based calling conventions.
  2. pregen/h/clink.h provides a header file to link the assembly functions with C or C++ code.

Making the C Linkable Functions Only for Other Compilers Using the Pregenerated Files

  1. This will only be possible, of course, if the included pregenerated files are "good enough" for your local setup. :)
  2. The two directories you will probably want to study are pregen/masm_inl/cdecl for C files containing inline MASM syntax assembly, and pregen/watcom/stack for WASM syntax assembly files using __cdecl calling conventions. Note that WASM is supposed to be a subset of MASM, so the latter files should work with any MASM compatiable assembler.
  3. pregen/h/clink.h provides a header file to link the assembly or C functions with C or C++ code.

Making the C Linkable Functions Only for GCC From Scratch

  1. Have a look config.gnu in the base directory, to make sure that the macros EXESUFFIX and ASMFORMAT make sense for your platform. (They are configured for a Linux, ELF, gas system by default.)
  2. cd asmgen and execute make -f makefile.gnu. This should produce a set of *.S files that can be translated by your assembler into object files.
  3. Translate the *.S files into object files using your choosen assembler.
  4. clink.h provides a header file to link the assembly functions with C or C++ code.

Making the C Functions Only for MSVC++ From Scratch

  1. cd asmgen and execute nmake /f makefile.ms. This should produce a set of *.c files containing inline assembly code that MSVC++ can compile into object files.
  2. clink.h provides a header file to link the assembly functions with C or C++ code.

Making the C Linkable Functions Only for Watcom From Scratch

  1. Have a look at the macro ASMFORMAT in config.wat in the base directory. This macro should equal wasm-register if you want to build functions that will be linkable with C using the register calling conventions. If you would like to use functions linkable using the __cdecl (stack) calling conventions select wasm-cdecl instead.
  2. cd asmgen and execute wmake /f makefile.wat. This should produce a set of *.asm files that can be translated by WASM into object files.
  3. The header for linking these functions with C or C++ is clink.h.

Making the C Linkable Functions Only for Other Compilers From Scratch

  1. The assembly generators are in the asmgen directory. No advanced C++ is used, so hopefully any decent C++ compiler will be able to translate the *.cpp into object files without a problem.
  2. Link the object files created from cmd5.cpp, asmgen.cpp, md5g.cpp and a2r128.cpp together to create the program cmd5. Repeat, substituting "rmd128" for "md5" to create the program crmd128.
  3. Link the object files created from csha0.cpp, shag.cpp, sha0g.cpp, asmgen.cpp, and a2r160.cpp together to create the program csha0. Repeat, substituting "sha1" for "sha0" to create the programs csha1.
  4. Link the object files created from crmd160.cpp, rmd160.cpp, asmgen.cpp, and a2r160.cpp together to create the program crmd160.
  5. Run the program cmd5 for a usage summary. (Note that wasm-cdecl should produce a file that MASM compatiable assemblers can translate into C linkable object files.)
  6. Run cmd5 with the desired assembly format as an option and redirect the output to create assembly files or C files with inline assembly as appropriate.
  7. Repeat the previous step for crmd128, crmd160, csha0, and csha1.
  8. The header for linking these functions with C or C++ code is clink.h.

Making the C Linkable Functions and the C++ Wrappers for GCC

  1. Have a look at config.gnu in the base directory to make sure that the macros EXESUFFIX, ASSEMBLER, ASMOUT, and ASMFORMAT make sense for your platform. (They are configured for a Linux, ELF, gas system by default.)
  2. Execute make -f makefile.gnu install to make a local installation under the base directory.
  3. Execute make -f makefile.gnu correct to perform a correctness check on the library.
  4. If you have a Pentium, execute make -f makefile.gnu speed to see the cycle counts for the compression functions.
  5. You can now move the header files from include/chnhash to an appropriate location for your system.
  6. The library lib/libch.a can now be moved to an appropriate location for your system.

Making the C Functions and the C++ Wrappers for MSVC++

  1. Execute nmake -f makefile.ms install to make a local installation under the base directory.
  2. Execute nmake -f makefile.ms correct to perform a correctness check on the library.
  3. If you have a Pentium, execute nmake -f makefile.ms speed to see the cycle counts for the compression functions.
  4. You can now move the header files from include/chnhash to an appropriate location for your system.
  5. The library lib/ch.lib can now be moved to an appropriate location for your system.

Making the C Linkable Functions and the C++ Wrappers for Watcom

  1. You will need Watcom C/C++ version 11.0 to build this library.
  2. Have a look at the macro ASMFORMAT in config.wat in the base directory. This macro should equal wasm-register if you want to build functions that will be linkable with C using the register calling conventions. If you would like to use functions linkable using the __cdecl (stack) calling conventions select wasm-cdecl instead.
  3. Ensure that the calling conventions specified in the macro CPPFLAGS are consistent with the above choice: Use /5r for register calling conventions and /5s for stack calling conventions.
  4. Execute wmake -f makefile.wat install to make a local installation under the base directory.
  5. Execute wmake -f makefile.wat correct to perform a correctness check on the library.
  6. If you have a Pentium, execute wmake -f makefile.wat speed to see the cycle counts for the compression functions.
  7. You can now move the header files from include/chnhash to an appropriate location for your system.
  8. The library lib/ch.lib can now be moved to an appropriate location for your system.

Making the C Linkable Functions and the C++ Wrappers for Other Compilers

The three main things that you will need a plan on how to handle before attempting a port to another compiler are:

If you think you can work around the above areas, the remainder of the port should be fairly easy, since this library does not use advanced C++ features.

  1. First, follow the instructions for building the C linkable functions only either from scratch, or using the pregenerated files.
  2. Copy the assembly files or C files containg inline assembly to chnhash.
  3. Copy asmgen/clink.h to the chnhash directory.
  4. Compile all the C++ files in chnhash. Make sure that the base directory is on your include path when you do this.
  5. Either translate the assembly files into object files or compile the C files containing inline assembly into object files.
  6. Link all the object files into a library and install it under lib in the base directory.
  7. Copy all the files chnhash/*.h, chnhash/*.hpp, and chnhash/*.inl to the directory include under the base directory.
  8. You now have a local installation, and can cd into tests to try out the correctness and speed tests.
  9. The headers and library can now be installed in appropriate locations for your system.
  10. Please mail me any stories about attempted ports to other compilers, or if you would like my help. I would also be grateful if anyone who performs a succesful port could translate the above steps into a makefile that I can make available to others.

Next Previous Table of Contents