OS X Magic++ problems

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
wing

OS X Magic++ problems

Post by wing »

I'm using Eclipse as an IDE for writing something in C++
It's procedural C++, as I didn't want to add learning C++ objects to learning C++
I've had ImageMagick installed and working for ages.
However, the Magick++ libs don't seem to be working.

Code: Select all

#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <Magick++.h>
// added argc and argv, as per recommendation on Magick++ homepage
int main( int /*argc*/, char ** argv) 
{
	InitializeMagick(argv);
	
	Image imGeometry(w, h), "black");
	
	return 0;
}
When I try to build the project, the following gcc invocation occurs

Code: Select all

g++ -O0 -g3 -Wall -c -fmessage-length=0 -MMD -MP -MF"project.d" -MT"project.d" -o"project.o" "../project.cpp"
which is what resulted in working code before I added the Magick++ stuff

Following the gcc invocation, there are two reported errors:

Code: Select all

../project.cpp:109: error: 'InitializeMagick' was not declared in this scope
../project.cpp:116: error: 'Image' was not declared in this scope
I've read the 'gentle introduction to Magick++' and I tried to follow its pattern, but it doesn't seem to have helped.

Any help would be appreciated.
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: OS X Magic++ problems

Post by magick »

Try adding
  • using namespace std;
    using namespace Magick;
to your source code.
wing

Re: OS X Magic++ problems

Post by wing »

As seems to be the trend with me and C++, solving the first caused more.

Code: Select all

Undefined symbols:
  "Magick::InitializeMagick(char const*)", referenced from:
      _main in project.o
  "Magick::Geometry::~Geometry()", referenced from:
      _main in project.o
      _main in project.o
  "Magick::Color::Color(char const*)", referenced from:
      _main in project.o
  "Magick::Color::~Color()", referenced from:
      _main in project.o
      _main in project.o
  "Magick::Image::~Image()", referenced from:
      _main in project.o
      _main in project.o
  "Magick::Image::Image(Magick::Geometry const&, Magick::Color const&)", referenced from:
      _main in project.o
  "Magick::Geometry::Geometry(unsigned int, unsigned int, unsigned int, unsigned int, bool, bool)", referenced from:
      _main in project.o
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: OS X Magic++ problems

Post by magick »

Verify the compile works outside Eclipse:
  • c++ -o example example.cpp `Magick++-config --cppflags --cxxflags --ldflags --libs`
wing

Re: OS X Magic++ problems

Post by wing »

Works like a charm.
Thanks Magick
I'll log the problem with the Eclipse people.
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: OS X Magic++ problems

Post by magick »

Type `Magick++-config --cppflags --cxxflags --ldflags --libs` on the command line and it will reveal the compile flags and load libraries required to properly link Magick++ to your application.
Post Reply