postgresql-hll icon indicating copy to clipboard operation
postgresql-hll copied to clipboard

Windows support

Open ylasri opened this issue 7 years ago • 1 comments

Any support for windows ?

ylasri avatar Jan 16 '19 17:01 ylasri

I have successfully installed this extension on Win 11 for PostgreSQL 15.6

  • Install MSYS2 from https://www.msys2.org/
  • Launch MINGW64 console
  • pacman -U https://repo.msys2.org/mingw/mingw64/mingw-w64-x86_64-postgresql-15.3-3-any.pkg.tar.zst
  • pacman --needed -S git mingw-w64-x86_64-gcc base-devel
  • git clone https://github.com/citusdata/postgresql-hll.git

Then patch src/hll.c file:

At the beginning:

#if defined(__APPLE__)
#include <libkern/OSByteOrder.h>
#define bswap_64 OSSwapInt64
#elif defined(__FreeBSD__) || defined(__DragonFly__)
#include <sys/endian.h>
#define bswap_64 bswap64
#elif defined(_WIN32)                           // <--- ADD THIS
#define bswap_64(x)     _byteswap_uint64((x))   // <--- ADD THIS
#else
#include <byteswap.h>
#endif

Big thanks to this gist https://gist.github.com/0017031/6b13fcb57a8463b77fa79628e2a73ee1

And at the ~2058 line of code replace: errmsg("expthresh modifier must be between -1 and %ld", expthresh_max))) by errmsg("expthresh modifier must be between -1 and %ld", (long int)expthresh_max))) (add cast to long int)

Then run make and copy those files to POSTGRES_PATH\share\extension (e.g. C:\Program Files\PostgreSQL\15\share\extension):

  • hll.control
  • hll*.sql

And copy hll.dll to POSTGRES_PATH\lib (e.g. C:\Program Files\PostgreSQL\15\lib)

And since hll.dll depends on libintl-8.dll (look for it inside MSYS64_INSTALLATION_DIR\mingw64\bin), you need to copy this DLL to POSTGRES_PATH\bin (e.g. C:\Program Files\PostgreSQL\15\bin)

(you can check dependencies by simply typing ldd hll.dll inside MSYS2 console)

And then try to open psql console and run CREATE EXTENSION hll;

codercms avatar Apr 13 '24 00:04 codercms