LeFish
LeFish

Reputation: 25

Magick++ does not read Image

In my first magick++ Project I am trying to read an image, rotate it and save it.

This is the source:

#include <iostream>
#include <Magick++.h>
#include <stdio.h>

using namespace std; 
using namespace Magick; 

int main(int argc, char *argv[]) {
    if (argc < 3)
   {
       printf("Usage: %s <Input file> <Output file>", argv[0]);
        return 1;
   }

   try{
        printf("Opening... %s\n", argv[1]);
        Magick::Image image(argv[1]);

        printf("Rotating...\n");
        image.rotate(45);

        printf("Opening... %s\n", argv[2]);
        image.write(argv[2]);
   }

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

I compile the program with cmake (->msvc). It basically compiles fine, it just throws a lot of C4251 warnings of this form:

"Magick::PathMovetoRel::_coordinates": class "std::vector<Magick::Coordinate,std::allocator<Magick::Coordinate>>" erfordert eine DLL-Schnittstelle, die von Clients von class "Magick::PathMovetoRel" verwendet wird [C:\Users\jfi\Desktop\Hints_Scripts\InsortAP_Toolbox\VSCode\IMhelloworld_cmake\build\IMHelloWorld.vcxproj]

And one C4275 warning:

{
"resource": "/C:/Program Files/ImageMagick-7.0.9-Q8/include/Magick++/Exception.h",
"owner": "cmake-build-diags",
"code": "C4275",
"severity": 4,
"message": "class \"std::exception\" ist keine DLL-Schnittstelle und wurde als Basisklasse für die DLL-Schnittstelle class \"Magick::Exception\" verwendet [C:\\Users\\jfi\\Desktop\\Hints_Scripts\\InsortAP_Toolbox\\VSCode\\IMhelloworld_cmake\\build\\IMHelloWorld.vcxproj]",
"source": "MSVC",
"startLineNumber": 23,
"startColumn": 3,
"endLineNumber": 23,
"endColumn": 3
}

The program stops at reading the image. It does not give any errormessages. Can I add some verbosity to magick++?

Thanks for your help!

Upvotes: 1

Views: 644

Answers (1)

john
john

Reputation: 87944

From the documentation

Be sure to initialize the ImageMagick library prior to using the Magick++ library. This initialization is performed by passing the path to the ImageMagick DLLs (assumed to be in the same directory as your program) to the InitializeMagick() function call. This is commonly performed by providing the path to your program (argv[0]) as shown in the following example:

int main(int argc, char** argv)
{
InitializeMagick(*argv);

You aren't calling InitializeMagick

Upvotes: 2

Related Questions