Page 1 of 1

OS X Magic++ problems

Posted: 2008-06-11T16:09:14-07:00
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.

Re: OS X Magic++ problems

Posted: 2008-06-11T17:22:25-07:00
by magick
Try adding
  • using namespace std;
    using namespace Magick;
to your source code.

Re: OS X Magic++ problems

Posted: 2008-06-11T18:40:49-07:00
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

Re: OS X Magic++ problems

Posted: 2008-06-11T20:37:12-07:00
by magick
Verify the compile works outside Eclipse:
  • c++ -o example example.cpp `Magick++-config --cppflags --cxxflags --ldflags --libs`

Re: OS X Magic++ problems

Posted: 2008-06-11T21:12:51-07:00
by wing
Works like a charm.
Thanks Magick
I'll log the problem with the Eclipse people.

Re: OS X Magic++ problems

Posted: 2008-09-01T12:57:16-07:00
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.