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.