Page 1 of 1

MAGICKCORE_QUANTUM_DEPTH=8 chops filenames??

Posted: 2014-11-13T12:54:45-07:00
by nido
I have a strange experience here with Magick++. if i define "-DMAGICKCORE_QUANTUM_DEPTH=8", somehow, it seems to chop off the first 8 characters of the file name it is given. (e.g. readImages(&img, "background.png"); -> terminate called after throwing an instance of: 'Magick::ErrorBlob'; what(): test: unable to open image `nd.png': No such file or directory @ error/blob.c/OpenBlob/2646

Short code sample that exhibits this behaviour:

Code: Select all

#include <list>
#include <Magick++.h>
     
int main(int argc, char* argv[]){
      std::list<Magick::Image> img;
      readImages(&img, argv[1]);
}


Compile: gcc -lstdc++ -std=c++11 test.cpp -DMAGICKCORE_HDRI_ENABLE=false -DMAGICKCORE_QUANTUM_DEPTH=8 -I/usr/include/ImageMagick-6 -lMagick++-6.Q16 -lMagickCore-6.Q16 -o test

To test: make a 'background.png' image available (or not; it will show regardless of its prescense)
./test background.png

observe the following errror:
terminate called after throwing an instance of 'Magick::ErrorBlob'
what(): Magick: unable to open image `nd.png': No such file or directory @ error/blob.c/OpenBlob/2646
Aborted (core dumped)

Now recompile with -DMAGICKCORE_QUANTUM_DEPTH=16
make sure background.png (or whatever filename you give it) is available.
run ./test background.png
No error!

Does anyone else see this behaviour?

Re: MAGICKCORE_QUANTUM_DEPTH=8 chops filenames??

Posted: 2014-11-13T13:11:37-07:00
by magick
Likely you are compiling with a quantum depth of 8 but dynamically linking with MagickCore or Magick++ library that was compiled with a quantum depth of 16. Try ldd to determine the path of the linkage or look for more than one instance of MagickCore and Magick++ on your system.

Re: MAGICKCORE_QUANTUM_DEPTH=8 chops filenames??

Posted: 2014-11-13T14:43:46-07:00
by snibgo
The program given in the OP runs without for me a problem with integer Q8. My bash compilation command was:

Code: Select all

$ c++ `Magick++-config --cxxflags --cppflags` -O2 -o rdtest rdtest.cpp `Magick++-config --ldflags --libs`
It is worth checking the two Magick++-config commands give reasonable links (eg to Q8 libraries) that are consistent with the defines.

It is possible to build all varieties of IM (Q8/Q16/Q32/Q64, integer/HDRI) on one machine, then compile/link against any variety. But if only one variety has been built, program compilations need the defines appropriate to that library.

Re: MAGICKCORE_QUANTUM_DEPTH=8 chops filenames??

Posted: 2014-11-13T15:55:00-07:00
by nido
Magick/snibgo
Thank you for clarifying the situation. The problem I was experiencing was a configuration error indeed related to linking to the wrong library version.

Re: MAGICKCORE_QUANTUM_DEPTH=8 chops filenames??

Posted: 2014-11-13T20:51:04-07:00
by snibgo
Just to say: I'm kicking myself for not spotting the obvious error in your compilation command:

-DMAGICKCORE_QUANTUM_DEPTH=8 ... -lMagick++-6.Q16 -lMagickCore-6.Q16

DEPTH of 8 won't work with Q16 libraries.

Re: MAGICKCORE_QUANTUM_DEPTH=8 chops filenames??

Posted: 2014-11-15T15:23:03-07:00
by nido
The reason I altered said number was because the warning # warning "you should set MAGICKCORE_QUANTUM_DEPTH to sensible default set it to configure time default" had me falsely assume I could just pick any depth I wanted (my error).

Right now I created something in CMake which choses a quantum depth based on the library name, because FindImageMagick doesn't seem to set this value: http://www.cmake.org/cmake/help/v3.0/mo ... agick.html

Is this a good way to configure this define or is there a batter way (within cmake) to do so. Thank you again for your time.

Re: MAGICKCORE_QUANTUM_DEPTH=8 chops filenames??

Posted: 2014-11-15T16:18:49-07:00
by snibgo
Personally, I configure/build IM libraries into different directories, according to Q8 integer, Q32 float-input, etc. Then I can build programs that reference a particular IM build with a simple tweak to PKG_CONFIG_PATH, eg:

Code: Select all

$ export PKG_CONFIG_PATH=~/iminst32f/lib/pkgconfig
$ cc -o wand wand.c `pkg-config --cflags --libs MagickWand`
But there are probably more elegant schemes.