What should I even include?

Magick++ is an object-oriented C++ interface to ImageMagick. Use this forum to discuss, make suggestions about, or report bugs concerning Magick++.
Post Reply
StephenLynx
Posts: 8
Joined: 2019-12-23T13:06:50-07:00
Authentication code: 1152

What should I even include?

Post by StephenLynx »

I'm using centOS 7, with ImageMagick-c++ 6.7.8.9-18.el7. And I can't include anything. If I include /usr/include/ImageMagick/magick/magic.h it fails. If I include /usr/include/ImageMagick/magick/magick.h it fails. It seem to have changed entirely on IM 7, so I can't seem to find useful information and the official docs only seem to refer to the latest version.

snibgo
Posts: 12936
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: What should I even include?

Post by snibgo »

For fairly recent versions, this works fine:

Code: Select all

#include <Magick++.h>
Your v6.7.8 is very very old, and may need something different. I suggest you upgrade.
snibgo's IM pages: im.snibgo.com

StephenLynx
Posts: 8
Joined: 2019-12-23T13:06:50-07:00
Authentication code: 1152

Re: What should I even include?

Post by StephenLynx »

Nope.
fatal error: Magick++.h: No such file or directory
Also, that's what centos ships. Even centos 8 ships 6.9. something.

StephenLynx
Posts: 8
Joined: 2019-12-23T13:06:50-07:00
Authentication code: 1152

Re: What should I even include?

Post by StephenLynx »

At this point it seems IM++ headers are trying to include files that don't exist.
/usr/include/ImageMagick/Magick++.h:9:30: fatal error: Magick++/Include.h: No such file or directory

Am I screwing up real bad or this is just not possible to use at all? The file it seems to refer is actually "ImageMagick/Magick++/Include.h".

snibgo
Posts: 12936
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: What should I even include?

Post by snibgo »

It works fine for me using v6.9.9-40 and older versions for the past couple of years. Your v6.7.8 is about seven years old, although it may have been "sort of" patched.
snibgo's IM pages: im.snibgo.com

StephenLynx
Posts: 8
Joined: 2019-12-23T13:06:50-07:00
Authentication code: 1152

Re: What should I even include?

Post by StephenLynx »

The issue was that you have to tell the compiler to include the whole IM header directory. Is that intentional? I ran into the same issue with bullet3d. If the includes are on the system path, why having to manually telling the compiler where to find them again?

snibgo
Posts: 12936
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: What should I even include?

Post by snibgo »

I suppose it depends on your build tools. I use the Gnu C tools, from Cygwin, on Windows 8.1. For IM v6, my bash build commands for Magick++ (cpp) programs are:

Code: Select all

export PKG_CONFIG_PATH=${IMDEV}../lib/pkgconfig

c++ -o "$1".exe "$1".cpp -Wall -Wa,-march=corei7,-mtune=corei7 `pkg-config --cflags --libs Magick++`

cp "$1".exe ${IMDEV}
... where ${IMDEV} is "C:\cygwin64\home\Alan\imdevins69940\bin\"

In the c++ command, the pkg-config subcommand expands to:

Code: Select all

-I/home/Alan/imdevins69940/include/ImageMagick-6 -fopenmp -DMAGICKCORE_HDRI_ENABLE=1 -DMAGICKCORE_QUANTUM_DEPTH=32 -L/home/Alan/imdevins69940/lib -lMagick++-6.Q32HDRI -lMagickWand-6.Q32HDRI -lMagickCore-6.Q32HDRI
Your directory names and Q-number will be different.
snibgo's IM pages: im.snibgo.com

StephenLynx
Posts: 8
Joined: 2019-12-23T13:06:50-07:00
Authentication code: 1152

Re: What should I even include?

Post by StephenLynx »

It's not because of my build tools: is because of the library headers using the wrong locations. You have the very same issue:
>-I/home/Alan/imdevins69940/include/ImageMagick-6
rigth at the start. Just because your tools automatically compensate the issue, it doesn't mean the issue is not there.

snibgo
Posts: 12936
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: What should I even include?

Post by snibgo »

As far as I know, compilers don't use the system path to find include files. The directory needs to be given in the c++ command.

/home/Alan/imdevins69940/include/ImageMagick-6 is the location of Magick++.h , which is the only header that I explicitly require. Other header files are in subdirectories of that.
snibgo's IM pages: im.snibgo.com

StephenLynx
Posts: 8
Joined: 2019-12-23T13:06:50-07:00
Authentication code: 1152

Re: What should I even include?

Post by StephenLynx »

From: https://commandlinefanatic.com/cgi-bin/ ... cle=art026

GCC looks in several different places for headers. On a normal Unix system, if you do not instruct it otherwise, it will look for headers requested with #include <file> in:

/usr/local/include
libdir/gcc/target/version/include
/usr/target/include
/usr/include

StephenLynx
Posts: 8
Joined: 2019-12-23T13:06:50-07:00
Authentication code: 1152

Re: What should I even include?

Post by StephenLynx »

The very first user is already having issues with my released project. His distro puts the headers on /usr/include/ImageMagick-7 instead of usr/include/ImageMagick. See how this issue affects portability?

snibgo
Posts: 12936
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: What should I even include?

Post by snibgo »

Well, that's what pkg-config is for. It means the c++ command doesn't have any explicit reference to directories. The directories come from the substitution of the pkg-config command. My IM headers are not in /usr/include/anything, but are in different directories for different versions of IM.

pkg-config gets the include directory from Magick++.pc, which I think is created from the "--prefix" option to the ./configure command.
snibgo's IM pages: im.snibgo.com

Post Reply