Page 1 of 1

Linker errors using magick++ with visual studio 05

Posted: 2011-09-16T08:48:57-07:00
by magic_user1
Hello,

I just found out about this library yesterday and have been trying to get it to work with visual studio 2005. I downloaded the windows installer and installed it and also tried to compile the code to generate libraries. Both approaches did install some libraries but none of them would work with my project.

The following is the linker error I get,

Error 2 error LNK2019: unresolved external symbol "__declspec(dllimport) public: virtual __thiscall Magick::Image::~Image(void)" (__imp_??1Image@Magick@@UAE@XZ) referenced in function "public: void __thiscall picedit::OnBnClickedButton1(void)" (?OnBnClickedButton1@picedit@@QAEXXZ) picedit.obj

Error 3 error LNK2019: unresolved external symbol "__declspec(dllimport) public: void __thiscall Magick::Image::read(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)" (__imp_?read@Image@Magick@@QAEXABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@Z) referenced in function "public: void __thiscall picedit::OnBnClickedButton1(void)" (?OnBnClickedButton1@picedit@@QAEXXZ) picedit.obj

Error 4 error LNK2019: unresolved external symbol "__declspec(dllimport) public: __thiscall Magick::Image::Image(void)" (__imp_??0Image@Magick@@QAE@XZ) referenced in function "public: void __thiscall picedit::OnBnClickedButton1(void)" (?OnBnClickedButton1@picedit@@QAEXXZ) picedit.obj

Any one has any idea about what I am doing wrong ? I have all my libs and dlls in a folder, the path of which is inside the linker properties.

Thanks in Advance

Re: Linker errors using magick++ with visual studio 05

Posted: 2011-09-16T10:30:29-07:00
by magick
You probably need to compile ImageMagick from source. ImageMagick binaries are compiled with VisualStudio 2010 and we suspect there may be a C++ name mangling issue. Perhaps not. Go to c:\Program Files\ImageMagick-6.7.2-6\Magick++_demo and click on the button workspace. Build and run. If that works, you can use the Button workspace as a template for your own custom project.

Re: Linker errors using magick++ with visual studio 05

Posted: 2011-09-16T15:10:42-07:00
by magic_user1
Thanks for the reply. I did try to compile the libraries from the source and still having issues. I looked at the demo button example and even though it compiles properly it crashes when run.

I tried to comment out some lines in the button example and now it shows a window about "Writing to button_out.miff" and crashes, below is the code which produces this error. Any suggestions on what I could be missing ?

Code: Select all

// Initialize ImageMagick install location for Windows
  InitializeMagick(*argv);

  try {

    string srcdir("");
    if(getenv("SRCDIR") != 0)
      srcdir = getenv("SRCDIR");

    //
    // Options
    //

    string backGround = "xc:#CCCCCC"; // A solid color

    // Color to use for decorative border
    Color border = "#D4DCF3";

    // Button size
    string buttonSize = "120x20";

    // Button background texture
    string buttonTexture = "granite:";

    // Button text
    string text = "Button Text";

    // Button text color
    string textColor = "red";

    // Font point size
    int fontPointSize = 16;

    //
    // Magick++ operations
    //

    Image button;

    // Set button size
 //   button.size( buttonSize );

    // Read background image
   // button.read( backGround );

    // Set background to buttonTexture
  //  Image backgroundTexture( buttonTexture );
   // button.texture( backgroundTexture );

    // Add some text
  //  button.fillColor( textColor );
    button.fontPointsize( fontPointSize );
    button.annotate( text, CenterGravity );

    // Add a decorative frame
    button.borderColor( border );
    button.frame( "6x6+3+3" );

    button.depth( 8 );

    // Quantize to desired colors
    // button.quantizeTreeDepth(8);
    button.quantizeDither(false);
    button.quantizeColors(64);
    button.quantize();

    // Save to file
    cout << "Writing to \"button_out.miff\" ..." << endl;
    button.compressType( RLECompression );
    button.write("button_out.miff");

    // Display on screen
    // button.display();

  }
  catch( exception &error_ )
    {
      cout << "Caught exception: " << error_.what() << endl;
      return 1;
    }

  return 0;
}