From a133fe4a21338aac3b9844cac866219be9d638ce Mon Sep 17 00:00:00 2001 From: Nathan Fiedler Date: Sat, 1 Jun 2024 11:34:11 -0700 Subject: [PATCH] doc: attempt at instructions for Windows --- INSTALL.md | 26 +++++++++++++++++++++++++- README.md | 22 +++++++++++----------- src/wand/magick.rs | 4 +++- 3 files changed, 39 insertions(+), 13 deletions(-) diff --git a/INSTALL.md b/INSTALL.md index 405287d..93a3def 100644 --- a/INSTALL.md +++ b/INSTALL.md @@ -43,6 +43,28 @@ curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh . "$HOME/.cargo/env" ``` +## Installing on Windows + +Using the MSVC build tools installer seems to be difficult since it installs a 32-bit version of LLVM. Maybe there is a better way to get Clang, so if you know, feel free to file an issue and/or pull request. + +In the mean time, we will be using MSYS since that works. + +### MSYS2 + +Visit the [MSYS2](https://www.msys2.org/) web site and follow the instructions for installation. Open a terminal and then install all of the prerequistes for building magick-rust (Clang, ImageMagick, pkg-config, and Rust). + +```shell +pacman -S git mingw-w64-x86_64-clang mingw-w64-x86_64-imagemagick mingw-w64-x86_64-pkg-config mingw-w64-x86_64-rust +export PATH=$PATH:/mingw64/bin +export IMAGE_MAGICK_LIBS='libMagickCore-7.Q16HDRI.dll.a;libMagickWand-7.Q16HDRI.dll.a' +export IMAGE_MAGICK_INCLUDE_DIRS='C:/msys64/mingw64/include/ImageMagick-7;C:/msys64/mingw64/lib/clang/18/include' +export LIBCLANG_PATH=/mingw64/bin +``` + +**TODO:** However, the unit tests for the generated bindings fail on the size of a long double. See [issue #124](https://github.com/nlfiedler/magick-rust/issues/124) for details. + +## Creating an Example + Create the example and copy the code that follows into the `src/main.rs` file. ```shell @@ -90,7 +112,9 @@ cargo run Hopefully that produced a `thumbnail-cat.jpg` file. -### Debugging +## Debugging + +### Linux builds Maybe that failed with the "failed to read file" error, in which case you can double-check that the image libraries were found and linked into the final binary. Use the `ldd` tool as shown below to make sure there are no libraries that were "not found". If there are any, make sure to install the requisite library, and then try `ldd` again. diff --git a/README.md b/README.md index 6fe6b21..c4e2056 100644 --- a/README.md +++ b/README.md @@ -25,8 +25,8 @@ For detailed examples, see the [INSTALL.md](./INSTALL.md) guide, along with some On FreeBSD, Linux, and macOS the following commands should suffice. ```shell -$ cargo build -$ cargo test +cargo build +cargo test ``` If `pkg-config` is not available, or you wish to override its behavior, you can set one or more environment variables before building. The `build.rs` script will pick these up and use them instead of trying to invoke the `pkg-config` utility. @@ -41,9 +41,9 @@ If `pkg-config` is not available, or you wish to override its behavior, you can When building on Windows, you will need to set the `IMAGE_MAGICK_DIR` environment variable to point to the ImageMagick installation path. Maybe this is possible with the `set` command, but it may be necessary to set the variable in the system preferences. Without setting `IMAGE_MAGICK_DIR`, the `build.rs` script will try to run `pkg-config` which is a tool generally found on Unix-based systems. ```shell -> set IMAGE_MAGICK_DIR= -> cargo build -> cargo test +$Env:IMAGE_MAGICK_DIR = '' +cargo build +cargo test ``` ## Documentation @@ -63,10 +63,10 @@ There are still many missing functions, so if you find there is something you wo [Docker](https://www.docker.com) can be used to build and test the code without affecting your development environment, which may have a different version of ImageMagick installed. The use of `docker compose`, as shown in the example below, is optional, but it makes the process very simple. ```shell -$ cd docker -$ docker compose build --pull -$ docker compose run magick-rust -$ cargo clean -$ cargo build -$ cargo test +cd docker +docker compose build --pull +docker compose run magick-rust +cargo clean +cargo build +cargo test ``` diff --git a/src/wand/magick.rs b/src/wand/magick.rs index 844be7b..956437e 100644 --- a/src/wand/magick.rs +++ b/src/wand/magick.rs @@ -35,8 +35,10 @@ use crate::{ CompressionType, DisposeType, DitherMethod, EndianType, FilterType, GravityType, Image, ImageType, InterlaceType, KernelInfo, LayerMethod, MagickEvaluateOperator, MagickFunction, MetricType, MorphologyMethod, OrientationType, PixelInterpolateMethod, PixelMask, - RenderingIntent, ResolutionType, ResourceType, StatisticType, + RenderingIntent, ResolutionType, StatisticType, }; +#[cfg(any(target_os = "linux", target_os = "macos"))] +use crate::ResourceType; wand_common!( MagickWand,