Skip to content

Commit

Permalink
doc: attempt at instructions for Windows
Browse files Browse the repository at this point in the history
  • Loading branch information
nlfiedler committed Jun 1, 2024
1 parent 77211e9 commit a133fe4
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 13 deletions.
26 changes: 25 additions & 1 deletion INSTALL.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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.

Expand Down
22 changes: 11 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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=<path to ImageMagick installation directory>
> cargo build
> cargo test
$Env:IMAGE_MAGICK_DIR = '<path\to\imagemagick>'
cargo build
cargo test
```

## Documentation
Expand All @@ -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
```
4 changes: 3 additions & 1 deletion src/wand/magick.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit a133fe4

Please sign in to comment.