building Enblend in Cygwin: patch included

2007-03-02
2013-01-01
  • Bill Clarke
    Bill Clarke
    2007-03-02

    This is a followup to the bug that various people have reported with Enblend for Windows in Windows Professional SP2.  I suspect it is a problem with GLEW, since GLEW also has similar problems (at least when I install GLEW 1.3.5 using cygwin it did): glewinfo and visualinfo (both supplied with GLEW) do not make it to main, failing with what I suspect is a linking problem.

    I've fixed the install of GLEW for Cygwin so it installs as a Cygwin library as opposed to a MinGW library.  See my message today (20070302) to the GLEW-users mailing list; <http://sourceforge.net/mailarchive/forum.php?forum=glew-users> (Hasn't been archived yet so no direct link).

    Plus I have succesfully built (a patched) Enblend 3.0 in Cygwin linking against the above patched GLEW and the current versions of the other dependencies Enblend has.  All of those other dependencies are available in Cygwin's binary repository: just run Cygwin's setup program to install them.

    The patch to Enblend does the following:
    - src/anneal.h: use std::isnan rather than plain isnan
    - src/enblend.cc: don't include <fenv.h>: Cygwin doesn't have it.  Use a short piece of inline assembler to set the floating-point rounding mode (copied from boost's interval library, you may need to check the license).
    - src/float_cast.h: Cygwin doesn't have llrint: copy MinGW's inline assembler versions of the conversion functions into here (this is in public domain).

    With this patch Enblend configures, builds, installs and runs succesfully.  I used the following configure:
    $ ./configure CPPFLAGS="-I/usr/include/boost-1_33_1 -I/usr/X11R6/include" CC="gcc" CXX="g++" LDFLAGS=-L/usr/X11R6/lib

    Patch follows:
    <<<
    diff -ur ../enblend-3.0/src/anneal.h enblend-3.0/src/anneal.h
    --- ../enblend-3.0/src/anneal.h    2004-11-21 20:23:08.000000000 +1100
    +++ enblend-3.0/src/anneal.h    2007-03-02 15:56:01.278849600 +1100
    @@ -399,7 +399,7 @@
                         //    printf("%08x         adj\n", 1072693248 - 60801);
                         //    printf("%08x%08x\n", eco.n.i, eco.n.j);
                         //}
    -                    if (isnan(piTAn)) {
    +                    if (std::isnan(piTAn)) {
                             // exp term is infinity or zero.
                             if (ej > E[i]) piTAn = 0.0;
                             else piTAn = piT;
    diff -ur ../enblend-3.0/src/enblend.cc enblend-3.0/src/enblend.cc
    --- ../enblend-3.0/src/enblend.cc    2007-01-28 07:05:39.000000000 +1100
    +++ enblend-3.0/src/enblend.cc    2007-03-02 17:53:28.892820800 +1100
    @@ -62,8 +62,10 @@
    extern "C" int optind;

    #ifndef _WIN32
    +#ifndef __CYGWIN__
    #include <fenv.h>
    #endif
    +#endif

    #include <signal.h>
    #include <stdlib.h>
    @@ -216,6 +218,11 @@
         // functions in float_cast.h will work properly.
         // See changes in vigra numerictraits.hxx
         _controlfp( _RC_NEAR, _MCW_RC );
    +#elif defined(__CYGWIN__)
    +    {
    +      unsigned short m = 0x137f;
    +      __asm__ __volatile__ ("fldcw %0" : : "m"(m));
    +    }
    #else
         fesetround(FE_TONEAREST);
    #endif
    diff -ur ../enblend-3.0/src/float_cast.h enblend-3.0/src/float_cast.h
    --- ../enblend-3.0/src/float_cast.h    2006-12-01 14:44:39.000000000 +1100
    +++ enblend-3.0/src/float_cast.h    2007-03-02 15:42:41.118275200 +1100
    @@ -35,7 +35,7 @@
    ** long int lrint  (double x) ;
    */

    -//#include "config.h"
    +#include "config.h"

    /* The presence of the required functions are detected during the configure
    ** process and the values HAVE_LRINT and HAVE_LRINTF are set accordingly in
    @@ -61,6 +61,78 @@
    #define    __USE_ISOC99    1

    #include    <math.h>
    +
    +#if defined(__CYGWIN__)
    +inline double __attribute__ ((__cdecl__)) rint (double x)
    +{
    +  double retval;
    +  __asm__ ("frndint;": "=t" (retval) : "0" (x));
    +  return retval;
    +}
    +
    +inline float __attribute__ ((__cdecl__)) rintf (float x)
    +{
    +  float retval;
    +  __asm__ ("frndint;" : "=t" (retval) : "0" (x) );
    +  return retval;
    +}
    +
    +inline long double __attribute__ ((__cdecl__)) rintl (long double x)
    +{
    +  long double retval;
    +  __asm__ ("frndint;" : "=t" (retval) : "0" (x) );
    +  return retval;
    +}
    +
    +inline long __attribute__ ((__cdecl__)) lrint (double x)
    +{
    +  long retval; 
    +  __asm__ __volatile__
    +    ("fistpl %0"  : "=m" (retval) : "t" (x) : "st");
    +  return retval;
    +}
    +
    +inline long __attribute__ ((__cdecl__)) lrintf (float x)
    +{
    +  long retval;
    +  __asm__ __volatile__
    +    ("fistpl %0"  : "=m" (retval) : "t" (x) : "st");
    +  return retval;
    +}
    +
    +inline long __attribute__ ((__cdecl__)) lrintl (long double x)
    +{
    +  long retval;
    +  __asm__ __volatile__
    +    ("fistpl %0"  : "=m" (retval) : "t" (x) : "st");
    +  return retval;
    +}
    +
    +inline long long __attribute__ ((__cdecl__)) llrint (double x)
    +{
    +  long long retval;
    +  __asm__ __volatile__
    +    ("fistpll %0"  : "=m" (retval) : "t" (x) : "st");
    +  return retval;
    +}
    +
    +inline long long __attribute__ ((__cdecl__)) llrintf (float x)
    +{
    +  long long retval;
    +  __asm__ __volatile__
    +    ("fistpll %0"  : "=m" (retval) : "t" (x) : "st");
    +  return retval;
    +}
    +
    +inline long long __attribute__ ((__cdecl__)) llrintl (long double x)
    +{
    +  long long retval;
    +  __asm__ __volatile__
    +    ("fistpll %0"  : "=m" (retval) : "t" (x) : "st");
    +  return retval;
    +}
    +
    +#endif
        
    #elif (defined (WIN32) || defined (_WIN32))

    >>>

    cheers,
    /lib

     
    • Ph.
      Ph.
      2007-03-05

      Sorry if I'm asking a little stupid; but as I am no programer I'm actually not able to understand how to use this information given by you?! :-( You've obviously had a lot of work with this: Thank you! But could you please give a "step by step-tutorial for dummies" (like me) what files (and how) one has to change so that enblend 3.0 can also be run on a Win XP Pro SP2?

      Thank you so much!
      phberlin

       
      • Bill Clarke
        Bill Clarke
        2007-03-05

        - You need do install Cygwin, with (at least) the following packages (the names may be wrong, sorry, I'm not at home right now):
        -- x (may be called xorg?), opengl
        -- libtiff-devel
        -- boost
        -- lcms
        -- plotutils or libxmi (sorry, can't remember which is the right name)

        - you need to download and install glew 1.3.6 (which includes my fixes for cygwin) inside cygwin:
        -- download the glew source
        -- start a cygwin shell
        -- uncompress/untar:
        $ tar zxfv glew-1.3.6.tgz
        [ or unzip glew-1.3.6.zip ]
        -- install:
        $ cd glew-1.3.6
        $ make
        $ make install
        -- this should install files in /usr/X11R6/include/GL, /usr/X11R6/bin and /usr/X11R6/lib.
        -- check that glewinfo and visualinfo (in /usr/X11R6/bin) work.  You may need to start X first by running "startx" (use the xterm that pops up to run glewinfo).

        - you need to download, patch and install enblend 3.0:
        -- download the enblend 3.0 source
        -- uncompress/untar/unzip
        -- patch the source files according to my patch.  You can do this by hand (replace the lines that have a leading - with the lines that have a leading +) or use the patch utility, if it's installed in cygwin:
        $ patch <patch-file
        -- configure enblend:
        $ cd enblend-3.0
        $ ./configure CPPFLAGS="-I/usr/include/boost-1_33_1 -I/usr/X11R6/include" CC="gcc" CXX="g++" LDFLAGS=-L/usr/X11R6/lib
        [ check that there were no warnings from configure ]
        $ make
        [ wait a while, in particular compiling enblend.cc takes a long time ]
        $ make install
        [ this puts enblend in /usr/local/bin ]

        You should now be able to run enblend from within Cygwin; you don't need to start X to do it.

        Note that --gpu does not work.

        I always run enblend by hand rather than from within e.g., hugin, so that's all I need.

        If you need it to be run from a windows program, let me know and I'll see if I can whip up a batch file.

        cheers,
        /lib

         
    • Ph.
      Ph.
      2007-03-05

      Huh, that does not sound like a simple task... To ask you frankly, couldn't you provide your patched enblend file, so that anyone encountering problems trying to run enblend 3.0 on WinXP Pro SP2 could just download your already patched enblend version and additionally download cygwin to make it work? As for me, I normally use enblend with the Enblend GUI and would like to have that work with enblend 3.0 also.

      As you can surely tell, I do not understand to much neither about the problems that cause enblend's partial malfunction nor about the compiling process to solve them, so maybe my suggestion is impossible as each one might have to compile for themselves or it won't work? I'm just a simple user, so my knowledge is too little to get behind the mysteries of all that. Sorry for that.

      So what do you think?

      Thank you, phberlin

       
    • Ph.
      Ph.
      2007-03-10

      Hhm, since you don't answer, I guess there is no way to do this like described above?

       
    • Bill Clarke
      Bill Clarke
      2007-03-11

      Sorry, I've been really busy.

      I have made a package available for download:

      <http://alto.anu.edu.au/~wpc/private/enblend/enblend-3.0-cyg.zip>.

      Download and unzip.  In the enblend-3.0-cyg folder there will be enblend.exe and all required dependencies (i.e., you do not need to install cygwin yourself).  You should be able to run enblend from within your favourite GUI tool / panorama front-end.

      (As much of this is covered by the GPL, I need to tell you that the source is available for all the libraries included; most of it is available from cygwin.com, other bits are enblend itself (enblend.sourceforge.net) and GLEW (glew.sourceforge.net).  I forgot to stick this in the package itself, but I'm sure no-one will complain.)

      Hopefully this will all work for you.

      cheers,
      /lib

       
      • david gunnells
        david gunnells
        2007-04-24

        Bill,
        First off, thanks for posting the fixed/rebuilt .zip package containing enblend w/ the cygwin dependencies.

        I'm wondering why the total size of all the files is > 24MB. :|  Your enblend, by itself, is 21MB when unzipped.

        Granted, a file that works is better than one that doesn't, but surely that's not as small as it can be built, right?

        Thanks,
        david

         
    • Ph.
      Ph.
      2007-03-11

      Hey, thank you so much!! I'm sure there are many people this is going to be useful for! I didn't have the chance to test it yet (as I'm busy too right now :-), but I'll post if I've gotten it to work. Again, thanks a lot!

      phberlin

       
    • Ph.
      Ph.
      2007-03-11

      It works just perfect (and amazingly fast, compared to v2.5)! I am using it with EnblendGUI without any problems now. Again, I'm really grateful, Bill -- thanks! :-)

       
    • Dave Anderson
      Dave Anderson
      2007-06-18

      It's three months later and this is still a problem. Is there only one programmer on the planet that knows how to build enblend? And why is the posted build cygwin dependent? Evolve to mingw if you must.

       
    • quaestor
      quaestor
      2007-06-29

      "It's three months later and this is still a problem"
      Perhaps it's ungrateful attitudes like yours which are keeping Bill away, genius.

      Oh, and if you're smart enough to know the difference between Cygwin and MinGW (proper spelling), BUILD IT YOUR DAMN SELF.

      As for me I say; THANKS BILL! Now I've got a working enblend, and I didn't have to build it myself. Oh, and my hard drive is certainly big enough to handle the extra 18.75 Megs...

       
      • Bill Clarke
        Bill Clarke
        2007-06-29

        Yeah no problem.  Glad to hear the Cygwin build is working for you.
        Unfortunately for the OP, I have:
        (a) recently moved country, and
        (b) no longer have a Windows machine
        so I
        1. am rather distracted at the moment and
        2. don't have much interest in providing a special MinGW build for Win XP.

        cheers,
        /lib

         
    • Farzackerly
      Farzackerly
      2008-05-18

      Many thanks, Bill, for doing this. I've just got into trying hugin and was tearing my hair out because enblend kept crashing. Your file works flawlessly.
      The first results were worth the perseverence.

       
    • Charlie L
      Charlie L
      2008-07-06

      Thank you Bill, it works a treat. The original files as well as the SSE were crashing upon starting, but this works well and straight through.