• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 543
  • Last Modified:

How do you use ImageMagick?

I have Windows XP and Visual C++ 6.0.  I downloaded ImageMagick, built the config program, ran it, and then built "VisualDynamicMT".  From the ImageMagick website, this sample program is given for resizing an image:

#include <Magick++.h>
#include <iostream>
using namespace std;
using namespace Magick;
int main(int argc,char **argv)
{
  // Construct the image object. Seperating image construction from the
  // the read operation ensures that a failure to read the image file
  // doesn't render the image object useless.
  Image image;
  try {
    // Read a file into image object
    image.read( "girl.gif" );

    // Crop the image to specified size (width, height, xOffset, yOffset)
    image.crop( Geometry(100,100, 100, 100) );

    // Write the image to a file
    image.write( "x.gif" );
  }
  catch( Exception &error_ )
    {
      cout << "Caught exception: " << error_.what() << endl;
      return 1;
    }
  return 0;
}

I compiled this with no errors (1 warning) but when I build it I get this:

--------------------Configuration: mytest - Win32 Debug--------------------
Linking...
mytest.obj : error LNK2001: unresolved external symbol "public: virtual __thiscall Magick::Image::~Image(void)" (??1Image@Magick@@UAE@XZ)
mytest.obj : error LNK2001: unresolved external symbol "public: void __thiscall Magick::Image::write(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)" (?write@Image@Magick@@QAEXABV?$basic_string@DU?$ch
ar_traits@D@std@@V?$allocator@D@2@@std@@@Z)
mytest.obj : error LNK2001: unresolved external symbol "public: __thiscall Magick::Geometry::~Geometry(void)" (??1Geometry@Magick@@QAE@XZ)
mytest.obj : error LNK2001: unresolved external symbol "public: void __thiscall Magick::Image::crop(class Magick::Geometry const &)" (?crop@Image@Magick@@QAEXABVGeometry@2@@Z)
mytest.obj : error LNK2001: unresolved external symbol "public: __thiscall Magick::Geometry::Geometry(unsigned int,unsigned int,unsigned int,unsigned int,bool,bool)" (??0Geometry@Magick@@QAE@IIII_N0@Z)
mytest.obj : error LNK2001: unresolved external symbol "public: void __thiscall Magick::Image::read(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)" (?read@Image@Magick@@QAEXABV?$basic_string@DU?$char
_traits@D@std@@V?$allocator@D@2@@std@@@Z)
mytest.obj : error LNK2001: unresolved external symbol "public: __thiscall Magick::Image::Image(void)" (??0Image@Magick@@QAE@XZ)
Debug/mytest.exe : fatal error LNK1120: 7 unresolved externals
Error executing link.exe.

mytest.exe - 8 error(s), 0 warning(s)

I have no idea what any of this means.  What do I need to do in order to use ImageMagick?
0
neoanderz
Asked:
neoanderz
1 Solution
 
jkrCommented:
You first need to build the library containing these functions from the files in 'Magick++/lib' - then, add the .lib to your project. Of yourse, you could also just add

Blob.cpp
BlobRef.cpp
CoderInfo.cpp
Color.cpp
Drawable.cpp
Exception.cpp
Functions.cpp
Geometry.cpp
Image.cpp
ImageRef.cpp
Montage.cpp
Options.cpp
Pixels.cpp
STL.cpp
Thread.cpp
TypeMetric.cpp

to your project, but IMHO using a .lib is 'cleaner'
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now