doc: attempt at instructions for Windows

This commit is contained in:
Nathan Fiedler
2024-06-01 11:34:11 -07:00
parent 77211e9568
commit a133fe4a21
3 changed files with 39 additions and 13 deletions

View File

@ -43,6 +43,28 @@ curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
. "$HOME/.cargo/env" . "$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. Create the example and copy the code that follows into the `src/main.rs` file.
```shell ```shell
@ -90,7 +112,9 @@ cargo run
Hopefully that produced a `thumbnail-cat.jpg` file. 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. 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.

View File

@ -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. On FreeBSD, Linux, and macOS the following commands should suffice.
```shell ```shell
$ cargo build cargo build
$ cargo test 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. 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. 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 ```shell
> set IMAGE_MAGICK_DIR=<path to ImageMagick installation directory> $Env:IMAGE_MAGICK_DIR = '<path\to\imagemagick>'
> cargo build cargo build
> cargo test cargo test
``` ```
## Documentation ## 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. [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 ```shell
$ cd docker cd docker
$ docker compose build --pull docker compose build --pull
$ docker compose run magick-rust docker compose run magick-rust
$ cargo clean cargo clean
$ cargo build cargo build
$ cargo test cargo test
``` ```

View File

@ -35,8 +35,10 @@ use crate::{
CompressionType, DisposeType, DitherMethod, EndianType, FilterType, GravityType, Image, CompressionType, DisposeType, DitherMethod, EndianType, FilterType, GravityType, Image,
ImageType, InterlaceType, KernelInfo, LayerMethod, MagickEvaluateOperator, MagickFunction, ImageType, InterlaceType, KernelInfo, LayerMethod, MagickEvaluateOperator, MagickFunction,
MetricType, MorphologyMethod, OrientationType, PixelInterpolateMethod, PixelMask, 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!( wand_common!(
MagickWand, MagickWand,