From 4493d60a397ac08ca3343d32cba481ad45313631 Mon Sep 17 00:00:00 2001 From: Don MacAskill Date: Mon, 1 Sep 2025 10:03:59 -0700 Subject: [PATCH 1/2] Add support for building a static library MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Some projects can’t or don’t want to link to a dynamic library, so build both to support more use cases. --- Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index be8bfee..b914690 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -15,7 +15,7 @@ rust-version = "1.81" [lib] name = "crc_fast" -crate-type = ["lib", "cdylib"] +crate-type = ["lib", "cdylib", "staticlib"] bench = true [dependencies] From b9c011e7c7269f5a1f281596172f600598a27975 Mon Sep 17 00:00:00 2001 From: Don MacAskill Date: Mon, 1 Sep 2025 10:22:22 -0700 Subject: [PATCH 2/2] Update README Include info about the static library option. --- README.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 855e925..ab8d831 100644 --- a/README.md +++ b/README.md @@ -24,7 +24,7 @@ So I wrote one. :) ## Other languages -Supplies a [C/C++ compatible shared library](#cc-compatible-shared-library) for use with other non-`Rust` languages. +Supplies a [C/C++ compatible library](#cc-compatible-library) for use with other non-`Rust` languages. ## Implementations @@ -39,8 +39,7 @@ See [CHANGELOG](CHANGELOG.md). ## Build & Install `cargo build` will obviously build the library, including -the [C-compatible shared library](#c-compatible-shared-library). There are fine-tuning [feature flags](Cargo.toml) -available, should they be necessary for your deployment and [acceleration](#acceleration-targets) targets. +the [C-compatible library](#cc-compatible-library). A _very_ basic [Makefile](Makefile) is supplied which supports `make install` to install the shared library and header file to @@ -248,11 +247,12 @@ let checksum = checksum_file_with_params(custom_params, file_on_disk, None); assert_eq!(checksum.unwrap(), 0xcbf43926); ``` -## C/C++ compatible shared library +## C/C++ compatible library `cargo build` will produce a shared library target (`.so` on Linux, `.dll` on Windows, `.dylib` on macOS, etc) and an auto-generated [libcrc_fast.h](libcrc_fast.h) header file for use in non-Rust projects, such as through -[FFI](https://en.wikipedia.org/wiki/Foreign_function_interface). +[FFI](https://en.wikipedia.org/wiki/Foreign_function_interface). It will also produce a static library target (`.a` on Linux and macOS, `.lib` on Windows, etc) for projects +which prefer statically linking. There is a [crc-fast PHP extension](https://github.com/awesomized/crc-fast-php-ext) using it, for example.