26 December 2011

OpenEXR with MinGW

I'm planning on updating my largest compile endeavor of err GTKGraphics Suite 2.0 however inkscape 0.49 seems take a bit more time (they are waiting for cairo 1.10.3?) obviously I'm reluctant to make inkscape 0.48.x build as it was the slowest before 0.49 (refactoring release). Then I'm thrilled that nip2 finally can directly open exr without crashing (no need to manually convert into .v image first).

However I wonder why openexr can't use pthreads under MinGW (note: I'm using pthread-win32 2.9) which I follow this build guide previously. Have a look at the following headers on IlmBase 1.0.1 (also in 1.0.2):
IlmThread.h, IlmThreadMutex.h, IlmThread and IlmThreadSemaphore.h

Clearly there is #ifdefs discrepancies..
Since openexr assume there is no pthread in win32/win64 platform but MinGW have it and automatically enabled during configure. Here is my patch for that issue, we also might need to add include string.h in some source files but that depends on which w32api version.

then for b44ExpLogTable issue we can add this line in our buildscript after make clean and before make install:

cd IlmImf
g++ $CFLAGS $(pkg-config --cflags
IlmBase) b44ExpLogTable.cpp -o b44ExpLogTable $(pkg-config --libs IlmBase)
cd $SRCS/openexr


For openexr 1.7.0 we need to commenting out #define ZLIB_WINAPI in ImfZipCompressor.cpp & ImfPxr24Compressor.cpp, version 1.6.1 doesn't have this yet.

In the end when we do make check, we should be able to pass all tests like my logs here

And as usual I use my own MinGW toolchains :-)

2 comments:

  1. Hello, can you please re-upload your patch file?

    It want be very nice :)!

    ReplyDelete
    Replies
    1. --- IlmThread/IlmThread.h Wed Jun 06 09:33:30 2007
      +++ IlmThread/IlmThread.h Sun Dec 25 23:05:20 2011
      @@ -99,10 +99,11 @@
      #define NOMINMAX
      #include
      #include
      -#elif HAVE_PTHREAD
      +#endif
      +#if HAVE_PTHREAD
      #include
      #endif

      #if defined(OPENEXR_DLL) && !defined(ZENO_STATIC)
      #ifdef ILMTHREAD_EXPORTS
      #define ILMTHREAD_EXPORT __declspec(dllexport)
      @@ -135,9 +135,9 @@

      private:

      - #if defined _WIN32 || defined _WIN64
      + #if (defined _WIN32 || defined _WIN64) && !defined HAVE_PTHREAD
      HANDLE _thread;
      #elif HAVE_PTHREAD
      pthread_t _thread;
      #endif

      --- IlmThread/IlmThreadMutex.h Tue Dec 12 11:17:35 2006
      +++ IlmThread/IlmThreadMutex.h Sun Dec 25 23:09:02 2011
      @@ -74,10 +74,11 @@
      #endif
      #define NOMINMAX
      #include
      -#elif HAVE_PTHREAD
      +#endif
      +#if HAVE_PTHREAD
      #include
      #endif

      namespace IlmThread {

      class Lock;
      @@ -95,9 +95,9 @@
      void lock () const;
      void unlock () const;

      - #if defined _WIN32 || defined _WIN64
      + #if (defined _WIN32 || defined _WIN64) && !defined HAVE_PTHREAD
      mutable CRITICAL_SECTION _mutex;
      - #elif HAVE_PTHREAD
      + #else
      mutable pthread_mutex_t _mutex;
      #endif

      --- IlmThread/IlmThreadSemaphore.h Tue Dec 12 11:17:47 2006
      +++ IlmThread/IlmThreadSemaphore.h Sun Dec 25 23:10:15 2011
      @@ -50,12 +50,13 @@
      #endif
      #define NOMINMAX
      #include
      -#elif HAVE_PTHREAD && !HAVE_POSIX_SEMAPHORES
      +#endif
      +#if HAVE_PTHREAD && !HAVE_POSIX_SEMAPHORES
      #include
      #elif HAVE_PTHREAD && HAVE_POSIX_SEMAPHORES
      #include
      #endif

      namespace IlmThread {


      @@ -73,11 +73,12 @@

      private:

      - #if defined _WIN32 || defined _WIN64
      + #if (defined _WIN32 || defined _WIN64) && !defined HAVE_PTHREAD

      mutable HANDLE _semaphore;
      + #endif

      - #elif HAVE_PTHREAD && !HAVE_POSIX_SEMAPHORES
      + #if HAVE_PTHREAD && !HAVE_POSIX_SEMAPHORES

      //
      // If the platform has Posix threads but no semapohores,

      Delete