-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support for Windows #19
Comments
Hi Jacob, I've yet to try compiling on a Windows machine but am happy to help get it working. We'll need to add the relevant paths to the <wishful-thinking> Is there a "standard" location for the Are you using MinGW or similar? |
The easiest way to compile node addon on windows is to install VS Express and Python 2.7. |
Sorry, @lovell, for not responding earlier. I started going with I am using MinGW. So far, this is what I've encountered and how far I've gotten:
I'm just now learning about gyp, so I'm slowly muddling through this. If you guys have any tips for getting past these issues, I'll be sure to document the steps and maybe update |
Drat. Even with a given VIPS for Windows distribution, the VS compiler chokes on some GCC-specific code in the |
Hi, I'm the libvips maintainer. The gcc-specific code is a bug caused by a dropped patch. Paste this into vips.h or use libvips master: |
+1 |
1 similar comment
👍 |
The official vips win32 builds now include a libvips.dll. Would this help? I'm told it works with VS, though I've not tried it myself. http://www.vips.ecs.soton.ac.uk/supported/7.40/win32/ 7.40.10 and later. The (background: although libvips has been able to build a DLL for quite a few years, some of the projects it wraps cannot. 7.40.10 and later leave out all these static-library-only projects and so you get a libvips.dll. This binary cannot load FITS or Matlab files.) |
+1 |
Hello to the +1s of the Noveo Group and welcome Microsofter @itsananderson. I'm sure the Would anyone like to have a go at adding it to the work-in-progress shell script that is https://github.com/lovell/sharp/blob/preinstall/preinstall.sh ? |
Finally had a chance to dig in tonight. Got the preinstall.sh doing a (brittle) download and unzip of the libvips binary. Also updated the binding.gyp to conditionally use relative paths to for lib and includes. https://github.com/itsananderson/sharp/tree/preinstall This is definitely more proof-of-concept than anything close to being ready to ship, but at least it's a step in the right direction. After gyp was able to start building, I hit a compile error. Apparently the VS implementation of C++11 doesn't support explicit array initializers. Fixed that (I think), by moving the array initialization into the struct's constructor body. Not super comfortable in C++, so there may be a better way to do that. I also added a reference to <algorithm> for std:min and std:max. That should be something we can hide behind a compile time flag. Once those issues were gone, I got a new error during linking:
I also tried libvipsCC-38.dll, but got the same result. At this point I'm quite far outside my knowledge of C++ and node-gyp. I don't think that file is actually corrupted (tried re-downloading), but maybe gyp is expecting a |
Hi @itsananderson, yes at compile-time you need to link against You'll need to test carefully, unfortunately. I made the DLL on a linux machine using a cross-compiler that implements something like VC6. The DLL will link to the system This is very unfortunate :-( I hope it doesn't cause too many problems for you. |
Ah, thanks. I just tried linking against
Basically, it's the same errors as when I completely leave out the reference to the libvips binary. |
Yes, You'll probably find you need a few other libraries as well. There's a sample build line here: http://www.vips.ecs.soton.ac.uk/index.php?title=Supported#Development_on_Windows |
Thanks @itsananderson, I've added the required source code changes you discovered to master. It looks like you've made good progress with the linking side of things too, great news. Are you able to get |
I've tried getting pkg-config working on Windows. It runs, and outputs the "right" flags, but it looks like the VS build system expects different inputs. e.g.
I think manual configuration of libs and include_dirs may, unfortunately, be required (unless there's an easy way to do compatibility conversion). Still getting a bunch of errors like this:
These errors make it seem like a bunch of |
The John's comment about linking against
Thank you for persisting with this. If we can get it working you'll have lots of new friends :) |
The pkg-config outputs unix style flags, and as far as I can tell, node-gyp adds the windows flags when it creates the John mentioned |
Hi, sorry for the delay, I've been away. Yes, pkg-config outputs flags for the compiler that was used to produce the package which made the .pc file, so mingw for the precompiled vips DLL. You won't be able to use it directly in MSVC, but it might help to see things like library ordering. You're right, the libvips dll.a does not have the -38 in there, sorry. It should work though! I tried this link line off the vips site: i686-w64-mingw32-g++ \
-mms-bitfields -march=i686 \
-I.../vips-dev-7.40.4/include \
-I.../vips-dev-7.40.4/include/glib-2.0 \
-I.../vips-dev-7.40.4/lib/glib-2.0/include \
hello.cc \
-L.../vips-dev-7.40.4/lib \
-lvipsCC -lvips -lgsf-1 -lz -ljpeg -lxml2 -lfftw3 -lm \
-lMagickWand-6.Q16 -llcms2 \
-lopenslide -lpangoft2-1.0 -ltiff -lpng14 -lexif \
-lMagickCore-6.Q16 -lpango-1.0 -lfreetype -lfontconfig -lgobject-2.0 \
-lgmodule-2.0 -lgthread-2.0 -lglib-2.0 -lintl \
-o hello.exe with this program: #include <iostream>
#include <vips/vips>
int
main( int argc, char **argv )
{
/* Check arguments.
*/
if( argc != 3 ) {
std::cerr << "usage: " << argv[0] << " infile outfile\n";
exit( 1 );
}
try {
vips::VImage fred( argv[1] );
fred.invert().write( argv[2] );
}
catch( vips::VError e ) {
e.perror( argv[0] );
}
return( 0 );
} and it works for me, though obviously with mingw rather than MSVC. Hopefully just swap it to MSVC link syntax and you should be done. Try a tiny vips program and see if you can get that to link. |
I am trying to install the latest version of sharp without any of the above mentioned modifications. I get the following error
node-gyp works fine on other projects of course, as I have VS and python installed. Is there anything I can do to test any of these changes or help move this along? |
@blowsie Please can you try changing |
+1 I also tried to
I tried again, freezing the console just after the package was downloaded, and edited
Got a slightly different error:
|
@michaeldrotar I think you may be experiencing a different problem to @blowsie as you're not seeing the The I now have in my possession a new Windows 8.1 laptop so hope to make a bit more progress with this. Please do keep adding comments to this issue about your own attempts of getting it working as these all help narrow down the problems. (On a multi-platform note, I managed to get libvips and sharp working on an ARMv6 Raspberry Pi over Christmas. WebP support was the trickiest bit to get working.) |
+1 |
👍 would love to move from gm to Sharp for actual good streaming support :D |
Thanks John. There's probably an option to allow the MS C++ linker to work with C variables in DLLs but I don't know MSVC well enough. Can anyone help? What I can do for now is temporarily wrap the new |
It used to be the case that DLLs just did not support external variables, only external functions. DLLs worked like this: a set of stubs would be added to the calling object, one for each entry point in the DLL. Each stub was initialised with a JMP to linking code. At runtime, if execution hit one of these things, it would trigger the linking routine to load the DLL into memory, if it wasn't already loaded, then to search it for the target function, and then to modify the stub to be a direct jump to the target. This is straightforward to implement and means there's no need for a full run-time linker, as you find on *nixes. The downside is that it can only support simple forward linking of function calls; you can't link external variables, and you can't do things like back linking. Perhaps the situation has improved since I last looked at this. |
I had a quick look at the normalise function, it looks nice. You could make it a bit more concise with
You could also consider taking a histogram of L* and setting the range to 1% and 99%, ie. letting the top 1% and the bottom 1% over- and under-expose. This would make it less sensitive to noise and probably produce a more pleasing image in more cases.
https://github.com/jcupitt/libvips/blob/master/libvips/histogram/percent.c#L82 |
Hide WebP format and normalise option Separate test runners for node and iojs
The @jcupitt The use of vips_object_local and vips_object_local_array will go away with #152. Your suggested improvements for normalisation are in #200, thank you. |
Ah great ... yes, #152 should be a nice improvement to readability. |
Support for Windows now in git master - will be published to npm shortly. |
Support for Windows now available in v0.10.0 via npm https://www.npmjs.com/package/sharp Thanks for everyone's help with this year-long task! Please create a new issue for any problems/improvements you discover. |
Great news! thanks everyone and @lovell 👍 |
Sadly, Following the installation instructions on the readme, I get the following error Windows: 8.1
|
@blowsie Is VIPS_HOME set? Does the $(VIPS_HOME)/include directory exist? |
Thanks @lovell, I did have them set, but you prompted me to restart, which did the trick. Maybe I should know by now to restart after setting variables, or maybe it should be added to the readme. :) |
The To test it, run |
@lovell ooo, nice work! Thanks |
As well as ease-of-installation, it looks like support for 64-bit node.exe on Windows will also be arriving in the next release v0.12.0. What problems, if any, would anyone who has contributed here have with sharp dropping support for 32-bit Windows from that version onwards? |
On v0.12.0 , I'm have proxy issues with the request to Update: In bindings.js there is a request to the libvibs library @ I think this request should be proxy aware. How about using shelljs to obtain the npm proxy config via |
@blowsie The Are you setting npm's https-proxy setting? If so, this might be available at install time for us to manually pass along to the request module, but I'd need to check. |
Yep My .npmrc file looks something like this.
I will try an use the environment vairables now, thanks. 👍 |
Setting the environment variables, and restarting the machine did not work for me :(. Perhaps using the npm config for this is not such a bad idea. |
http://thenextweb.com/microsoft/2015/12/03/office-365-is-down-for-many-users-in-europe/ suggests we might not be able to take the credit for that.
Will take a look, thanks for confirming. |
Update: using the environment variables did infact work, the reason the installation still did not work was because the file at So using the environment variables does actually fix the problem, but may effect other applications, like "Skype for Business" in my case |
@lovell Works a charm thank you very much. I look forward to the next release. |
@blowsie Great, thanks for confirming. |
@blowsie v0.12.1 now available via npm |
I'd like to be able to use sharp on the Windows platform. Because
libvips
is available for Windows, I assume that lack of support is mostly in figuring out the build script.Has this been investigated already? If so, what approaches have already been tried and roadblocks encountered? Knowing what's been tried so far, if anything, will help me or other potential developers come to a working solution quicker.
The text was updated successfully, but these errors were encountered: