Question

I am trying libvips for visual studio 2012, starting with a simple example at http://www.vips.ecs.soton.ac.uk/supported/current/doc/html/vipsmanual/vipsmanualse1.html#x6-60001.1.1

#include <iostream>  
#include <vips/vips>  

int  
main (int argc, char ⋆⋆argv)  
{  
  if (argc != 3)  
    {  
      std::cerr << "usage: " << argv[0] << " infile outfile\n";  
      return (1);  
    }  

  try  
  {  
    vips::VImage fred (argv[1]);  

    fred.invert ().write (argv[2]);  
  }  
  catch (vips::VError e)  
  {  
    e.perror (argv[0]);  
  }  

  return (0);  
}

What I did was:

Download and extract libvips at http://www.vips.ecs.soton.ac.uk/supported/7.34/win32/

Add to VC++ Directories->Include directories as vips-dev-7.34.1\include (vips-dev-7.34.1 is the extracted folder)

Add to VC++ Directories->Library directories as vips-dev-7.34.1\lib

Add a system path entry as vips-dev-7.34.1\bin

Basically because there are not much guide on using libvips with visual studio, so I applied the procedure that I used for OpenCV. The guide only say "All you need to do is include . This will get all of the include you need". Aparrently there are much more than that.

Upon building, the first error is "Unable to find header file "glib-object.h". Essentially, vips/vips call glib-objects "include which lies inside a subfolder of include \include\glib-2.0\glib-objects.h. I searched for a way to make VS search for all subfolders within the main include folder, it seems that such "recursive search" is not possible in VS. One has to point exactly to the folder containing header file and I may need to add all of the subfolders manually. So I tried adding vips-dev-7.34.1\include\glib-2.0 to VC++ Directories->Include directories. But then glib-objects.h calls for another glibconfig.h which is nowhere to be found within the include folder and subfolders.

Have someone sucessfully make libvips work with VS? Can you give me some advices if I miss something.

Was it helpful?

Solution

I'm the libvips maintainer. Sorry, it's very difficult to use the pre-built libvips binaries with VS, for various reasons (see below). I think your options are to use mingw instead, to cross-compile from linux (this is what I do), or to rebuild libvips yourself from source using VS (perhaps a week's work for an experienced dev?). There are some notes on the vips website about this issue.

The libvips.dll on the website has been cross-compiled from linux using mingw. It's set up for a linux-style build system with pkg-config, so you will have a lot of compiler flags to figure out in VS, and it's built against msvcrt.dll, the Windows C runtime, rather than msvcrtXX.dll, the VS runtime, so you will have endless annoying compatibility problems unless you also build against the Windows runtime.

Unfortunately VS no longer supports building against the Windows runtime. They have an internal tool which does support this mode, but it's not publicly available. I read somewhere you can coax the DDK compiler into doing this, but it's also not supported.

CoApp is an interesting project (partly supported by Microsoft) that is attempting to make building software on Windows less painful, but it's still in beta. You could maybe ask if they have a libvips packaged up for VS, or are considering making one.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top