MinGW Configure Question (WINGDI32_DELEGATE)

Questions and postings pertaining to the development of ImageMagick, feature enhancements, and ImageMagick internals. ImageMagick source code and algorithms are discussed here. Usage questions which are too arcane for the normal user list should also be posted here.
Post Reply
User avatar
jonoomph
Posts: 27
Joined: 2011-03-27T14:25:09-07:00
Authentication code: 8675308

MinGW Configure Question (WINGDI32_DELEGATE)

Post by jonoomph »

Hi, I know MinGW is not the focus of ImageMagick, but hopefully I have a very simple question to answer. When running ./configure on the latest version of ImageMagick in MinGW on Windows 7, I was curious about the following snippet (from the ./configure script):

Code: Select all

if test "${GDI32_LIBS}x" != 'x'; then
  $as_echo "#define WINGDI32_DELEGATE 1" >>confdefs.h
fi

if test "${GDI32_LIBS}x" != 'x' ; then
  WINGDI32_DELEGATE_TRUE=
  WINGDI32_DELEGATE_FALSE='#'
else
  WINGDI32_DELEGATE_TRUE='#'
  WINGDI32_DELEGATE_FALSE=
fi
When I build on MinGW, I get the following errors (which I think are related to the above snippet in the ./configure script):

Code: Select all

...
  CC       coders/magick_libMagickCore_6_Q16_la-xcf.lo
  CC       coders/magick_libMagickCore_6_Q16_la-xpm.lo
  CC       coders/magick_libMagickCore_6_Q16_la-xps.lo
  CC       coders/magick_libMagickCore_6_Q16_la-ycbcr.lo
  CC       coders/magick_libMagickCore_6_Q16_la-yuv.lo
  CC       coders/magick_libMagickCore_6_Q16_la-clipboard.lo
  CC       coders/magick_libMagickCore_6_Q16_la-emf.lo
coders/emf.c:45:0: warning: ignoring #pragma comment  [-Wunknown-pragmas]
 #  pragma comment(lib, "gdiplus.lib")
 ^
In file included from ./magick/blob.h:21:0,
                 from coders/emf.c:47:
./magick/image.h:53:3: error: 'PaletteType' redeclared as different kind of symbol
   PaletteType,
   ^
In file included from c:\mingw\include\gdiplus/gdiplus.h:56:0,
                 from c:\mingw\include\gdiplus.h:25,
                 from coders/emf.c:44:
c:\mingw\include\gdiplus/gdipluspixelformats.h:92:3: note: previous declaration of 'PaletteType' was here
 } PaletteType;
   ^
In file included from ./magick/blob.h:21:0,
                 from coders/emf.c:47:
./magick/image.h:61:3: error: conflicting types for 'ImageType'
 } ImageType;
   ^
In file included from c:\mingw\include\gdiplus/gdiplus.h:49:0,
                 from c:\mingw\include\gdiplus.h:25,
                 from coders/emf.c:44:
c:\mingw\include\gdiplus/gdiplusenums.h:523:3: note: previous declaration of 'ImageType' was here
 } ImageType;
   ^
In file included from ./magick/fx.h:21:0,
                 from ./magick/gem.h:21,
                 from ./magick/pixel-accessor.h:22,
                 from coders/emf.c:59:
./magick/draw.h:83:3: error: conflicting types for 'LineCap'
 } LineCap;
   ^
In file included from c:\mingw\include\gdiplus/gdiplus.h:49:0,
                 from c:\mingw\include\gdiplus.h:25,
                 from coders/emf.c:44:
c:\mingw\include\gdiplus/gdiplusenums.h:556:3: note: previous declaration of 'LineCap' was here
 } LineCap;
   ^
In file included from ./magick/fx.h:21:0,
                 from ./magick/gem.h:21,
                 from ./magick/pixel-accessor.h:22,
                 from coders/emf.c:59:
./magick/draw.h:91:3: error: conflicting types for 'LineJoin'
 } LineJoin;
   ^
In file included from c:\mingw\include\gdiplus/gdiplus.h:49:0,
                 from c:\mingw\include\gdiplus.h:25,
                 from coders/emf.c:44:
c:\mingw\include\gdiplus/gdiplusenums.h:563:3: note: previous declaration of 'LineJoin' was here
 } LineJoin;
   ^
coders/emf.c: In function 'ReadEMFImage':
coders/emf.c:168:11: error: expected expression before ':' token
   Gdiplus::Bitmap
           ^
coders/emf.c:171:3: error: duplicate label 'Gdiplus'
   Gdiplus::BitmapData
   ^
coders/emf.c:168:3: note: previous definition of 'Gdiplus' was here
   Gdiplus::Bitmap
   ^
coders/emf.c:171:11: error: expected expression before ':' token
   Gdiplus::BitmapData
           ^
coders/emf.c:174:3: error: duplicate label 'Gdiplus'
   Gdiplus::GdiplusStartupInput
   ^
coders/emf.c:168:3: note: previous definition of 'Gdiplus' was here
   Gdiplus::Bitmap
   ^
coders/emf.c:174:11: error: expected expression before ':' token
   Gdiplus::GdiplusStartupInput
           ^
coders/emf.c:177:3: error: duplicate label 'Gdiplus'
   Gdiplus::Graphics
   ^
coders/emf.c:168:3: note: previous definition of 'Gdiplus' was here
   Gdiplus::Bitmap
   ^
coders/emf.c:177:11: error: expected expression before ':' token
   Gdiplus::Graphics
           ^
coders/emf.c:180:3: error: duplicate label 'Gdiplus'
   Gdiplus::Image
   ^
coders/emf.c:168:3: note: previous definition of 'Gdiplus' was here
   Gdiplus::Bitmap
   ^
coders/emf.c:180:11: error: expected expression before ':' token
   Gdiplus::Image
           ^
coders/emf.c:183:3: error: duplicate label 'Gdiplus'
   Gdiplus::Rect
   ^
coders/emf.c:168:3: note: previous definition of 'Gdiplus' was here
   Gdiplus::Bitmap
   ^
coders/emf.c:183:11: error: expected expression before ':' token
   Gdiplus::Rect
           ^
coders/emf.c:221:7: error: 'Gdiplus' undeclared (first use in this function)
   if (Gdiplus::GdiplusStartup(&token,&startup_input,NULL) != 
       ^
coders/emf.c:221:7: note: each undeclared identifier is reported only once for each function it appears in
coders/emf.c:221:14: error: expected ')' before ':' token
   if (Gdiplus::GdiplusStartup(&token,&startup_input,NULL) != 
              ^
coders/emf.c:225:3: error: 'source' undeclared (first use in this function)
   source=Gdiplus::Image::FromFile(fileName);
   ^
coders/emf.c:225:17: error: expected ';' before ':' token
   source=Gdiplus::Image::FromFile(fileName);
                 ^
coders/emf.c:226:25: error: expected ')' before ':' token
   if (source == (Gdiplus::Image *) NULL)
                         ^
coders/emf.c:228:7: error: duplicate label 'Gdiplus'
       Gdiplus::GdiplusShutdown(token);
       ^
coders/emf.c:168:3: note: previous definition of 'Gdiplus' was here
   Gdiplus::Bitmap
   ^
coders/emf.c:228:15: error: expected expression before ':' token
       Gdiplus::GdiplusShutdown(token);
               ^
coders/emf.c:245:49: error: expected ')' before ':' token
           image->columns=(size_t) floor((Gdiplus::REAL) source->GetWidth() /
                                                 ^
coders/emf.c:245:57: error: expected ')' before 'source'
           image->columns=(size_t) floor((Gdiplus::REAL) source->GetWidth() /
                                                         ^
coders/emf.c:247:45: error: expected ')' before ':' token
           image->rows=(size_t)floor((Gdiplus::REAL) source->GetHeight() /
                                             ^
coders/emf.c:247:53: error: expected ')' before 'source'
           image->rows=(size_t)floor((Gdiplus::REAL) source->GetHeight() /
                                                     ^
coders/emf.c:252:3: error: 'bitmap' undeclared (first use in this function)
   bitmap=new Gdiplus::Bitmap((INT) image->columns,(INT) image->rows,
   ^
coders/emf.c:252:10: error: 'new' undeclared (first use in this function)
   bitmap=new Gdiplus::Bitmap((INT) image->columns,(INT) image->rows,
          ^
coders/emf.c:252:14: error: expected ';' before 'Gdiplus'
   bitmap=new Gdiplus::Bitmap((INT) image->columns,(INT) image->rows,
              ^
coders/emf.c:254:3: error: 'graphics' undeclared (first use in this function)
   graphics=Gdiplus::Graphics::FromImage(bitmap);
   ^
coders/emf.c:254:19: error: expected ';' before ':' token
   graphics=Gdiplus::Graphics::FromImage(bitmap);
                   ^
coders/emf.c:255:41: error: expected ')' before ':' token
   graphics->SetInterpolationMode(Gdiplus::InterpolationModeHighQualityBicubic);
                                         ^
coders/emf.c:256:37: error: expected ')' before ':' token
   graphics->SetSmoothingMode(Gdiplus::SmoothingModeHighQuality);
                                     ^
coders/emf.c:257:41: error: expected ')' before ':' token
   graphics->SetTextRenderingHint(Gdiplus::TextRenderingHintClearTypeGridFit);
                                         ^
coders/emf.c:258:26: error: expected ')' before ':' token
   graphics->Clear(Gdiplus::Color((BYTE) ScaleQuantumToChar(QuantumRange-
                          ^
coders/emf.c:264:3: error: unknown type name 'delete'
   delete graphics;
   ^
coders/emf.c:265:3: error: unknown type name 'delete'
   delete source;
   ^
coders/emf.c:267:3: error: 'rect' undeclared (first use in this function)
   rect=Gdiplus::Rect(0,0,(INT) image->columns,(INT) image->rows);
   ^
coders/emf.c:267:15: error: expected ';' before ':' token
   rect=Gdiplus::Rect(0,0,(INT) image->columns,(INT) image->rows);
               ^
coders/emf.c:268:37: error: expected ')' before ':' token
   if (bitmap->LockBits(&rect,Gdiplus::ImageLockModeRead,PixelFormat32bppARGB,
                                     ^
coders/emf.c:269:29: error: expected ')' before ':' token
     &bitmap_data) != Gdiplus::Ok)
                             ^
coders/emf.c:271:5: error: unknown type name 'delete'
     delete bitmap;
     ^
coders/emf.c:272:5: error: duplicate label 'Gdiplus'
     Gdiplus::GdiplusShutdown(token);
     ^
coders/emf.c:168:3: note: previous definition of 'Gdiplus' was here
   Gdiplus::Bitmap
   ^
coders/emf.c:272:13: error: expected expression before ':' token
     Gdiplus::GdiplusShutdown(token);
             ^
coders/emf.c:271:12: warning: unused variable 'bitmap' [-Wunused-variable]
     delete bitmap;
            ^
coders/emf.c:279:25: error: 'bitmap_data' undeclared (first use in this function)
     p=(unsigned char *) bitmap_data.Scan0+(y*abs(bitmap_data.Stride));
                         ^
coders/emf.c:301:3: error: unknown type name 'delete'
   delete bitmap;
   ^
coders/emf.c:302:3: error: duplicate label 'Gdiplus'
   Gdiplus::GdiplusShutdown(token);
   ^
coders/emf.c:168:3: note: previous definition of 'Gdiplus' was here
   Gdiplus::Bitmap
   ^
coders/emf.c:302:11: error: expected expression before ':' token
   Gdiplus::GdiplusShutdown(token);
           ^
coders/emf.c:301:10: warning: unused variable 'bitmap' [-Wunused-variable]
   delete bitmap;
          ^
coders/emf.c:265:10: warning: unused variable 'source' [-Wunused-variable]
   delete source;
          ^
coders/emf.c:264:10: warning: unused variable 'graphics' [-Wunused-variable]
   delete graphics;
          ^
coders/emf.c:205:5: warning: unused variable 'token' [-Wunused-variable]
     token;
     ^
coders/emf.c:168:3: warning: label 'Gdiplus' defined but not used [-Wunused-label]
   Gdiplus::Bitmap
   ^
make[2]: *** [coders/magick_libMagickCore_6_Q16_la-emf.lo] Error 1
make[2]: Leaving directory `/home/rmrf/im/ImageMagick-6.8.8-2'
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory `/home/rmrf/im/ImageMagick-6.8.8-2'
make: *** [all] Error 2
To solve the build error, I applied the following patch:

Code: Select all

-if test "${GDI32_LIBS}-x" != 'x'; then
  -$as_echo "#define WINGDI32_DELEGATE 1" >>confdefs.h
-fi
-
-if test "${GDI32_LIBS}x" != 'x' ; then
-  WINGDI32_DELEGATE_TRUE=
-  WINGDI32_DELEGATE_FALSE='#'
-else
   WINGDI32_DELEGATE_TRUE='#'
   WINGDI32_DELEGATE_FALSE=
-fi
It seems like many conflicts exist between the gdiplus header files (for example: gdipluspixelformats.h) and ImageMagick header files. And when I apply this patch, it seems to solve the build errors. However, I would love to hear somebody's thoughts on this error, and let me know how to avoid all the conflicting declarations between gdiplus and ImageMagick. And hopefully there is a simple explanation and solution. =)
User avatar
dlemstra
Posts: 1570
Joined: 2013-05-04T15:28:54-07:00
Authentication code: 6789
Contact:

Re: MinGW Configure Question (WINGDI32_DELEGATE)

Post by dlemstra »

Your build is broken because I recently integrated the code from emfplus.exe into the emf coder. This will be fixed in the next release.
.NET + ImageMagick = Magick.NET https://github.com/dlemstra/Magick.NET, @MagickNET, Donate
Post Reply