Page 1 of 1

Compilation error

Posted: 2008-08-16T16:06:51-07:00
by trentg
I'm trying to compile ImageMagick with MinGW/MSYS and I get the following error:

Code: Select all

trent@TRENT-VISTA /c/Users/trent/ImageMagick-6.4.2
$ make
c:/bin/make.exe  all-am
make.exe[1]: Entering directory `c:/Users/trent/ImageMagick-6.4.2'
C:/msys/1.0/bin/sh.exe ./libtool --tag=CC   --mode=link gcc  -g -O2 -Wall -W -no-undefined -dlpreopen ltdl/loadlibrary.la   -o ltdl/libltdlc.la  ltdl/loaders/ltdl_libltdlc_la-preopen.lo ltdl/ltdl_libltdlc_la-lt__alloc.lo ltdl/ltdl_libltdlc_la-lt_dlloader.lo ltdl/ltdl_libltdlc_la-lt_error.lo ltdl/ltdl_libltdlc_la-ltdl.lo ltdl/ltdl_libltdlc_la-slist.lo ltdl/argz.lo ltdl/lt__strl.lo 
libtool: link: rm -f ltdl/.libs/libltdlc.nm ltdl/.libs/libltdlc.nmS ltdl/.libs/libltdlc.nmT
libtool: link: (cd ltdl/.libs && gcc -g -O2 -Wall -W -c -fno-builtin  -DDLL_EXPORT -DPIC "libltdlcS.c")
libtool: link: rm -f "ltdl/.libs/libltdlcS.c" "ltdl/.libs/libltdlc.nm" "ltdl/.libs/libltdlc.nmS" "ltdl/.libs/libltdlc.nmT"
libtool: link: rm -fr  ltdl/.libs/libltdlc.a ltdl/.libs/libltdlc.lax
libtool: link: (cd ltdl/.libs/libltdlc.lax/loadlibrary.a && ar x "c:/Users/trent/ImageMagick-6.4.2/ltdl/.libs/loadlibrary.a")
libtool: link: ar cru ltdl/.libs/libltdlc.a ltdl/loaders/.libs/ltdl_libltdlc_la-preopen.o ltdl/.libs/ltdl_libltdlc_la-lt__alloc.o ltdl/.libs/ltdl_libltdlc_la-lt_dlloader.o ltdl/.libs/ltdl_libltdlc_la-lt_error.o ltdl/.libs/ltdl_libltdlc_la-ltdl.o ltdl/.libs/ltdl_libltdlc_la-slist.o ltdl/.libs/argz.o ltdl/.libs/lt__strl.o ltdl/.libs/libltdlcS.o  ltdl/.libs/libltdlc.lax/loadlibrary.a\loadlibrary.o 
c:\mingw\bin\ar.exe: ltdl/.libs/libltdlc.lax/loadlibrary.aloadlibrary.o: No such file or directory
make.exe[1]: *** [ltdl/libltdlc.la] Error 1
make.exe[1]: Leaving directory `c:/Users/trent/ImageMagick-6.4.2'
c:\bin\make.exe: *** [all] Error 2
That's with --silent removed from the libtool command line. Seems there is a \ where there should be a /, only I can't find it. Any help?

Thanks.

Re: Compilation error

Posted: 2008-08-16T16:17:51-07:00
by magick
Download ImageMagick 6.4.2-10 from ftp://magick.imagemagick.org/pub/ImageMagick/beta in about an hour. We updated the autoconf / automake / libtool configuration files. If the problem you reported persists, let us know.

Re: Compilation error

Posted: 2008-08-17T09:10:10-07:00
by trentg
Thanks. It compiled but now when I try to compile my program I'm getting a bunch of undefined references:

Code: Select all

Creating library file: ..\..\lib\liba5_icodecd.dll.a
c:/mingw/bin/../lib/gcc/mingw32/4.2.1-sjlj/../../../libMagick++.a(Exception.o):
In function `Exception':
Magick++/lib/Exception.cpp:29: undefined reference to `_imp___ZNSt9exceptionD2Ev
'
Magick++/lib/Exception.cpp:23: undefined reference to `_imp___ZNSt9exceptionD2Ev
'
Magick++/lib/Exception.cpp:23: undefined reference to `_imp___ZNSt9exceptionD2Ev
'
Magick++/lib/Exception.cpp:29: undefined reference to `_imp___ZNSt9exceptionD2Ev
'
c:/mingw/bin/../lib/gcc/mingw32/4.2.1-sjlj/../../../libMagick++.a(Exception.o):
In function `~Exception':
Magick++/lib/Exception.cpp:50: undefined reference to `_imp___ZNSt9exceptionD2Ev
'
c:/mingw/bin/../lib/gcc/mingw32/4.2.1-sjlj/../../../libMagick++.a(Exception.o):M
agick++/lib/Exception.cpp:50: more undefined references to `_imp___ZNSt9exceptio
nD2Ev' follow
collect2: ld returned 1 exit status
mingw32-make[2]: *** [lib/liba5_icodecd.dll] Error 1
mingw32-make[1]: *** [addons/icodec/CMakeFiles/a5_icodecd_shared.dir/all] Error
2
mingw32-make: *** [all] Error 2

The program looks like this:

Code: Select all

/*
 * Allegro Magick++ image loading/saving routines
 * author: Ryan Dickie (c) 2008
 * image magick supports these formats:
 *     http://www.imagemagick.org/script/formats.php
 */

#include "allegro5/allegro5.h"

#ifdef ALLEGRO_MSVC
   /* Needed by Magic++ */
   #define _VISUALC_
#endif
#include <Magick++.h>


extern "C" {
   #include "allegro5/icodec.h"

   static bool initialized = false;

   /* image magick++ reads/writes based on string format */
   /* FIXME: for some inexplicable reason these are opposite endianess
    * image magick problem or allegro5 weirdness? */
   std::string _pixel_format_string(int fmt) {
      switch (fmt) {
         case ALLEGRO_PIXEL_FORMAT_ARGB_8888:
            return "BGRA";
         case ALLEGRO_PIXEL_FORMAT_RGBA_8888:
            return "ABGR";
         case ALLEGRO_PIXEL_FORMAT_RGB_888:
            return "BGR";
         case ALLEGRO_PIXEL_FORMAT_ABGR_8888:
            return "RGBA";
         /* TODO other formats.. and what does the X mean? in BRGX_8888 */
         default:
            return "";
      }
   }

   ALLEGRO_BITMAP* al_load_image(const char* path) {
      try {
         Magick::Image in(path);
         const unsigned int width = in.columns();
         const unsigned int height = in.rows();
         ALLEGRO_BITMAP* bmp = al_create_bitmap(width,height);
         ALLEGRO_LOCKED_REGION lr;
         al_lock_bitmap(bmp, &lr, ALLEGRO_LOCK_WRITEONLY);
         std::string sfmt = _pixel_format_string(lr.format);
         if (sfmt == "") {
            fprintf(stderr, "Unsupported pixel format. Currently 24bpp and 32bpp only\n");
            return NULL;
         }
         fprintf(stderr, "Pixel format %s\n",sfmt.c_str());
         in.write(0,0,width,height, sfmt, Magick::CharPixel, lr.data);
         al_unlock_bitmap(bmp);
         return bmp;
      } catch( const std::exception& err ) {
         fprintf(stderr, "icodec load error: %s\n", err.what());
      } 
      return NULL;
   }
   
   int al_save_image(ALLEGRO_BITMAP* bmp, const char* path) {
      try {
         const unsigned int width = al_get_bitmap_width(bmp);
         const unsigned int height = al_get_bitmap_height(bmp);
         std::string sfmt = "";
         ALLEGRO_LOCKED_REGION lr;
         al_lock_bitmap(bmp, &lr, ALLEGRO_LOCK_READONLY);
         sfmt = _pixel_format_string(lr.format);
         if (sfmt == "") {
            fprintf(stderr, "Unsupported pixel format. Currently 24bpp and 32bpp only\n");
            return 0;
         }
         fprintf(stderr, "Pixel format %s\n",sfmt.c_str());
         Magick::Image out(width,height, sfmt, Magick::CharPixel, (const unsigned char *)(lr.data));
         al_unlock_bitmap(bmp);
         out.write(path);
         return 0;
      } catch( const std::exception& err ) {
         fprintf(stderr, "icodec write error: %s\n", err.what());
         return 1;
      } 
   }
} /* extern C */
Not sure how to resolve this. I'm linking in the proper order, Magick++, Wand, Core.

Re: Compilation error

Posted: 2008-08-17T10:34:04-07:00
by trentg
Well I got it to "work", but I had to remove all the "-D_DLL"s from the top level makefile as per this thread:

http://thread.gmane.org/gmane.comp.gnu.mingw.user/23481

I have a slight problem, that I compiled with PNG support by my test doesn't load PNGs. It does load PCX and TGA.