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: 6
Joined: 2011-08-06T06:21:56-07:00
Authentication code: 8675308

Installation problem under FreeBSD

Post by Imaginatorium » 2018-07-10T12:37:41-07:00

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: 10374
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Installation problem under FreeBSD

Post by snibgo » 2018-07-10T13:47:14-07:00

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: 10824
Joined: 2003-05-31T11:32:55-07:00

Re: Installation problem under FreeBSD

Post by magick » 2018-07-11T02:57:24-07:00

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`

Post Reply