Page 1 of 1

Installation problem under FreeBSD

Posted: 2018-07-10T12:37:41-07:00
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

Re: Installation problem under FreeBSD

Posted: 2018-07-10T13:47:14-07:00
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?

Re: Installation problem under FreeBSD

Posted: 2018-07-11T02:57:24-07:00
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`

Re: Installation problem under FreeBSD

Posted: 2018-07-26T04:33:58-07:00
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?

Re: Installation problem under FreeBSD

Posted: 2018-07-26T05:05:56-07:00
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?

Re: Installation problem under FreeBSD

Posted: 2018-08-07T13:00:07-07:00
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!