Page 1 of 1

Problem linking Magick++ with gcc - undefined reference.

Posted: 2010-02-23T12:19:38-07:00
by waffledonkey
I am trying to link my program with ImageMagick libs. I ran configure and then "make install". I am trying to statically link the libraries and the linker can find the libraries. The nm command shows that the symbols are in the libraries but I still cannot link. Every call into ImageMagick is met with an undefined reference.

: undefined reference to `Magick::Image::Image(std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)'
: undefined reference to `Magick::Geometry::Geometry(unsigned int, unsigned int, unsigned int, unsigned int, bool, bool)'
: undefined reference to `Magick::Image::zoom(Magick::Geometry const&)'
: undefined reference to `Magick::Geometry::~Geometry()'
: undefined reference to `Magick::Image::write(std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)'
: undefined reference to `Magick::Image::~Image()'

The sample programs built and ran so I am sure the compiler is fine. gcc version 3.4.6 20060404 (Red Hat 3.4.6-9)

Here is my link line:
linking @g++ -static -Wl,--allow-multiple-definition -L../utils/lib/release -L./bin/release -L../lib -L/usr/X11R6/lib -lMagick++ -lMagickCore -lMagickWand -lfreetype -lfontconfig -ldpstk -ldps -lXext -lXt -lSM -lICE -lX11 -lbz2 -lxml2 -lz -lm -lpthread -o bin/release/CmdLineClient ./obj/release/ImageMagick.o ./obj/release/CmdLineClient.o

Any help is greatly appreciated!!
Thanks,
Waffle

Re: Problem linking Magick++ with gcc - undefined reference.

Posted: 2010-02-23T13:19:11-07:00
by magick
Try this command:
  • g++ `Magick++-config --cxxflags --cppflags` -o CmdLineClient CmdLineClient.cpp `Magick++-config --ldflags --libs`

Re: Problem linking Magick++ with gcc - undefined reference.

Posted: 2010-02-23T19:04:12-07:00
by waffledonkey
Thanks! I had taken the output from the Magick-config and put it in my Makefile but obviously something went wrong. This will give me something to build on.

Re: Problem linking Magick++ with gcc - undefined reference.

Posted: 2011-04-14T09:17:30-07:00
by gonebaby
magick wrote:Try this command:
  • g++ `Magick++-config --cxxflags --cppflags` -o CmdLineClient CmdLineClient.cpp `Magick++-config --ldflags --libs`
Any chance you could adapt that for someone trying to use ImageMagick in a program being compiled with Dev-C++ in Windows 7?

I've been trying to get rid of these linker errors for ages, and I can't find anyone else on the internet using Windows, Dev-C++, and ImageMagick that's getting these errors. >_<

I have the same problem as waffledonkey, tons of undefined reference messages for my sample program:
[Linker error] undefined reference to `Magick::Image::Image()'
[Linker error] undefined reference to `Magick::Image::read(std::string const&)'

etc...

I've tried adding the .dll to my project's folder, including CORE_RL_Magick++_.lib in the linker, everything I can think of. Help!