davidbyttow / govips

A lightning fast image processing and resizing library for Go
MIT License
1.23k stars 196 forks source link

Cross-compiling to Windows almost works #402

Closed mholt closed 6 months ago

mholt commented 6 months ago

Thanks for this great package.

I'm trying to cross-compile a simple program that uses this to Windows (from Linux) using zig and it almost works:

$ CGO_ENABLED=1 \
  GOOS=windows \
  CC="zig cc -target x86_64-windows" \
  CXX="zig c++ -target x86_64-windows" \
  go build

# github.com/davidbyttow/govips/v2/vips
In file included from /home/matt/go/pkg/mod/github.com/davidbyttow/govips/v2@v2.13.0/vips/arithmetic.go:3:
./arithmetic.h:4:10: fatal error: 'vips/vips.h' file not found
#include <vips/vips.h>
         ^~~~~~~~~~~~~
1 error generated.

I know very little about cgo... do you happen to know a way to make it compile?

tonimelisma commented 6 months ago

Looks like it's not finding libvips at all. I'm sorry but we don't support Windows as a platform.

mholt commented 6 months ago

Thanks for the reply. I did see that in the readme. It looks like someone got it running natively on Windows and maybe I just need to figure out how to get the Windows libvips onto my system, or something...

Anyway, cheers :)

mholt commented 6 months ago

Update: I was able to get past the error above by downloading the libvips release for Windows, then extracting it into a folder, and using the -L and -I flags on the zig command to pass the folder paths for the libraries and includes, respectively, to the zig compiler. Of course, now I'm missing pthreads.h and other C libraries for Windows. I bet if we figure out a way to get those and use those, the method shown above could make Windows compatibility possible for this package.