Problem linking Magick++ with gcc - undefined reference.

Questions and postings pertaining to the development of ImageMagick, feature enhancements, and ImageMagick internals. ImageMagick source code and algorithms are discussed here. Usage questions which are too arcane for the normal user list should also be posted here.
Post Reply
waffledonkey

Problem linking Magick++ with gcc - undefined reference.

Post 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
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

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

Post by magick »

Try this command:
  • g++ `Magick++-config --cxxflags --cppflags` -o CmdLineClient CmdLineClient.cpp `Magick++-config --ldflags --libs`
waffledonkey

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

Post 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.
gonebaby
Posts: 4
Joined: 2011-04-14T08:58:02-07:00
Authentication code: 8675308

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

Post 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!
Post Reply