Installation problem under FreeBSD

Magick++ is an object-oriented C++ interface to ImageMagick. Use this forum to discuss, make suggestions about, or report bugs concerning Magick++.
Post Reply
Imaginatorium
Posts: 8
Joined: 2011-08-06T06:21:56-07:00
Authentication code: 8675308

Installation problem under FreeBSD

Post by Imaginatorium »

Can someone help me with getting Imagemagick++ to work under FreeBSD, or reinstall it? I have a small C++ program to do some basic image manipulation (basic, but very specific); it ran on my webserver (at pair.com hosting), but suddenly stopped working, because of some upgrade or other. When I tried to recompile my program, I got the following error messages:

Code: Select all

g++ `Magick++-config --ldflags --libs` imagetrim.o boundingbox.o -o imagetrim
imagetrim.o: In function `main':
imagetrim.cpp:(.text+0x3c1): undefined reference to `Magick::Image::read(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)'
imagetrim.cpp:(.text+0x783): undefined reference to `Magick::Image::write(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)'
imagetrim.cpp:(.text+0xd55): undefined reference to `Magick::Image::write(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)'
collect2: error: ld returned 1 exit status
*** Error code 1
Here's the makefile:

Code: Select all

CC=g++
CFLAGS=-c `Magick++-config --cxxflags --cppflags`
LDFLAGS=`Magick++-config --ldflags --libs`

SOURCES=main.cpp hello.cpp factorial.cpp imagetrim.cpp

OBJECTS=$(SOURCES:.cpp=.o)
EXECUTABLE=hello

all: $(SOURCES) $(EXECUTABLE)

cutout: cutout.o cutoutbg.o boundingbox.o
	$(CC) $(LDFLAGS) cutout.o cutoutbg.o boundingbox.o -o $@

cutpng: cutpng.o cutoutbg.o boundingbox.o bgp.h local.h
	$(CC) $(LDFLAGS) cutpng.o cutoutbg.o boundingbox.o -o $@

test: test.o cutoutbg.o boundingbox.o
	$(CC) $(LDFLAGS) test.o cutoutbg.o boundingbox.o -o $@

imagetrim: imagetrim.o boundingbox.o
	$(CC) $(LDFLAGS) imagetrim.o boundingbox.o -o $@

.cpp.o:
	$(CC) $(CFLAGS) $< -o $@

clean:
	rm -rf *o
Someone suggested that this is a loader problem, because the library has been compiled under a different version. I thought that perhaps the simplest way around this would be to install a copy of the Imagemagick++ libary in my own space, but I simply can't see how to do this. I don't really understand what the library object file would be called, for a start.

Can anyone give me any pointers in the right direction? TIA
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Installation problem under FreeBSD

Post by snibgo »

I suggest you follow the instructions at http://www.imagemagick.org/script/magick++.php . In particular:

1. export PKG_CONFIG_PATH

2. put `Magick++-config --ldflags --libs` at the end, not the start, of the compilation command.

Does that help?
snibgo's IM pages: im.snibgo.com
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: Installation problem under FreeBSD

Post by magick »

See https://www.imagemagick.org/script/magick++.php:

Code: Select all

c++ `Magick++-config --cxxflags --cppflags` -O2 -o imagetrim imagetrim.cpp boundingbox.cpp \
  `Magick++-config --ldflags --libs`
Imaginatorium
Posts: 8
Joined: 2011-08-06T06:21:56-07:00
Authentication code: 8675308

Re: Installation problem under FreeBSD

Post by Imaginatorium »

Thanks for responses. (I have been otherwise occupied.) Unfortunately, this gets me nowhere: my makefile has exactly the compiler command listed, except for the optimisation parameter. And it produces the following output, which is an error from ld. This seems to suggest there is a version discrepancy between the compiled Magick library and my currently compiled program...

Code: Select all

make imagetrim
g++ `Magick++-config --ldflags --libs` imagetrim.o boundingbox.o -o imagetrim
imagetrim.o: In function `main':
imagetrim.cpp:(.text+0x3c1): undefined reference to `Magick::Image::read(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)'
imagetrim.cpp:(.text+0x783): undefined reference to `Magick::Image::write(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)'
imagetrim.cpp:(.text+0xd55): undefined reference to `Magick::Image::write(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)'
collect2: error: ld returned 1 exit status
*** Error code 1

Stop.
make: stopped in /usr/home/horigome/c
Can anyone say anything definitive about what these messages mean?
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Installation problem under FreeBSD

Post by snibgo »

Your g++ command doesn't mention your source .cpp files, just your object .o files. Were the objects built under a previous version of IM? Did you try the command suggested by user magick? Did you try putting `Magick++-config --ldflags --libs` at the end?
snibgo's IM pages: im.snibgo.com
Imaginatorium
Posts: 8
Joined: 2011-08-06T06:21:56-07:00
Authentication code: 8675308

Re: Installation problem under FreeBSD

Post by Imaginatorium »

The full makefile is at the top of the thread; I did rm *.o to force all the .o files to be recompiled versions. I have tried moving the library arguments all over the g++ command, including right at the end, and before the output file, but it makes no difference.

I understand the basic idea of an object code library, which is searched for everything, but I cannot understand what file might be the relevant library; there are about fifty files in /usr/local/lib - the following are the ones starting libMagick - what would they all be?
libMagick++-6.Q16.a libMagick++-6.Q16.so.6
libMagick++-6.Q16.la libMagick++-6.Q16.so.6.0.0
libMagick++-6.Q16.so

Since there may be a problem with the library files installed by the hosting company, I could try to install my own version; but I do not understand what files exactly I would need to copy. Help!
Post Reply