Compiling problem with Magick++ on Ubuntu 12.04.2 LTS 64bit

Magick++ is an object-oriented C++ interface to ImageMagick. Use this forum to discuss, make suggestions about, or report bugs concerning Magick++.
Post Reply
Caffeinomane
Posts: 1
Joined: 2013-02-05T01:51:48-07:00
Authentication code: 6789

Compiling problem with Magick++ on Ubuntu 12.04.2 LTS 64bit

Post by Caffeinomane »

Hello, I am using a Ubuntu 12.04.2 LTS 64bit and I am trying to compile this simple program that I found somewhere on this forum:

Code: Select all

#include "Magick++.h"

using namespace std;
using namespace Magick;

void testbild()
{
  Image  image;
  image.read( "logo:");
  Geometry newSize = Geometry(720, 480);
  image.scale(newSize);
  image.write( "logo.png");
}

int main(int argc, char **argv)
{
   InitializeMagick(*argv);
   testbild(); // OK
   return 0;
}
But g++ refuses to compile it:

Code: Select all

$ g++ `Magick++-config --cppflags --cxxflags --ldflags --libs` -o prova prova.cpp
/tmp/cc2BtIjx.o: In function `testbild()':
prova.cpp:8: undefined reference to `Magick::Image::Image()'
prova.cpp:9: undefined reference to `Magick::Image::read(std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)'
prova.cpp:10: undefined reference to `Magick::Geometry::Geometry(unsigned long, unsigned long, long, long, bool, bool)'
prova.cpp:11: undefined reference to `Magick::Image::scale(Magick::Geometry const&)'
prova.cpp:12: undefined reference to `Magick::Image::write(std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)'
prova.cpp:12: undefined reference to `Magick::Geometry::~Geometry()'
prova.cpp:12: undefined reference to `Magick::Image::~Image()'
prova.cpp:12: undefined reference to `Magick::Image::~Image()'
prova.cpp:12: undefined reference to `Magick::Geometry::~Geometry()'
/tmp/cc2BtIjx.o: In function `main':
/home/fontana/Dropbox/Luca/prova.cpp:17: undefined reference to `Magick::InitializeMagick(char const*)'
collect2: ld returned 1 exit status
Yes I have installed the development package of this library

Code: Select all

$ Magick++-config --cppflags --cxxflags --ldflags --libs
-I/usr/include/ImageMagick
-g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Wformat-security -pthread
-L/usr/lib -Wl,-Bsymbolic-functions -Wl,-z,relro -L/usr/lib/X11
-L/usr/lib -lMagick++ -lMagickWand -lMagickCore -llcms -ltiff -lfreetype -ljpeg -llqr-1 -lglib-2.0 -lfontconfig -lXext -lSM -lICE -lX11 -lXt -lbz2 -lz -lm -lgomp -lpthread -lltdl

Code: Select all

$ ls /usr/lib/libMagick*
/usr/lib/libMagick++.a     /usr/lib/libMagickCore.so        /usr/lib/libMagick++.la    /usr/lib/libMagick++.so.4.0.1  /usr/lib/libMagickWand.so
/usr/lib/libMagickCore.a   /usr/lib/libMagickCore.so.4      /usr/lib/libMagick++.so    /usr/lib/libMagickWand.a       /usr/lib/libMagickWand.so.4
/usr/lib/libMagickCore.la  /usr/lib/libMagickCore.so.4.0.1  /usr/lib/libMagick++.so.4  /usr/lib/libMagickWand.la      /usr/lib/libMagickWand.so.4.0.1

Code: Select all

$ ls /usr/include/ImageMagick/Magick++*
/usr/include/ImageMagick/Magick++.h

/usr/include/ImageMagick/Magick++:
Blob.h  CoderInfo.h  Color.h  Drawable.h  Exception.h  Geometry.h  Image.h  Include.h  Montage.h  Pixels.h  STL.h  TypeMetric.h
I tried every combination of g++ options that I could find but nothig succeded. Does someone has any suggestion before I give up and use another library?
rtorrero
Posts: 3
Joined: 2013-02-26T04:40:59-07:00
Authentication code: 6789

Re: Compiling problem with Magick++ on Ubuntu 12.04.2 LTS 64

Post by rtorrero »

Seems we are having the same issue, just posted a similar message in the board, but using ubuntu 12.10 and i686 (also tested with x86_64).

Could you fix this?
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: Compiling problem with Magick++ on Ubuntu 12.04.2 LTS 64

Post by magick »

Here is the proper build command for a Magick++ module:
  • g++ `Magick++-config --cxxflags --cppflags` -O2 -Wall -o magick++ magick++.cpp `Magick++-config --ldflags --libs`
Post the output of that command if it fails.
rtorrero
Posts: 3
Joined: 2013-02-26T04:40:59-07:00
Authentication code: 6789

Re: Compiling problem with Magick++ on Ubuntu 12.04.2 LTS 64

Post by rtorrero »

How would this apply to code divided in multiple files? i've tried to adapt this to the makefile I posted in my thread (viewtopic.php?f=23&t=22864) but I've had no success so far, it fail building the "main" target (when the linkage is done) Any help is greatly appreciated
Post Reply