Compiling for arm-qnx and reading pdfs

Magick++ is an object-oriented C++ interface to ImageMagick. Use this forum to discuss, make suggestions about, or report bugs concerning Magick++.
Post Reply
stefan_a
Posts: 3
Joined: 2013-03-04T01:09:22-07:00
Authentication code: 6789

Compiling for arm-qnx and reading pdfs

Post by stefan_a »

Hi all,

it's kind of a hard problem an I am stucked at the moment. I hope it belongs here, because it consists of several distinct issues.
I want to use ImageMagick for reading password encrypted PDF-files on the new Blackberry 10 systems (arm-qnx). I had success in building a static library and use Magick++ in my Blackberry project to open images, but not PDFs. Missing ghostscript support might be the problem here. I will tell you the steps I made in case you want to check the configure-stuff for IM. I am working on ubuntu 12.10, 64bit and tried IM version 6.8.3-6 (and some others ).

The first problem was cross-compiling IM for arm-qnx. I use the compiler of the Blackberry SDK (you can get it for free here http://developer.blackberry.com/cascades/download/ ). I added a bunch of environment variables:
QNX_TARGET="/home/?/programs/bb10_ndk/target_10_0_10_261/qnx6"
QNX_HOST="/home/?/programs/bb10_ndk/host_10_0_10_534/linux/x86"
QNX_CONFIGURATION="/home/?/.rim/bbndk"
MAKEFLAGS="-I$QNX_TARGET/usr/include"
LD_LIBRARY_PATH="$QNX_HOST/usr/lib/:$QNX_TARGET/../linux/x86/usr/lib/qt4/lib:$LD_LIBRARY_PATH"
PATH="$QNX_HOST/usr/bin:$QNX_CONFIGURATION/bin:/home/?/programs/bb10_ndk/ide/linux/x86/eclipse/jre/bin:$PATH"
QDE=/home/?/programs/bb10_ndk/ide/linux/x86
CPUVARDIR=armle-v7


Then, I used the following to configure IM:
./configure CC="qcc -V4.6.3,gcc_ntoarmv7le" CFLAGS="-fPIC" CXX="qcc -V4.6.3,gcc_ntoarmv7le_cpp" CXXFLAGS="-fPIC" --host=arm --without-x --without-perl --with-quantum-depth=8 --prefix=/home/?/coding/work/ImageMagick-6.8.3-6/test_out --with-libstdc=/home/?/programs/bb10_ndk/target_10_0_10_261/qnx6/armle-v7/lib LIBS=-lsocket -with-gslib -with-gs

This runes fine in general, but I can see:
Ghostscript lib --with-gslib=yes no

During make, I get several compiler errors in magick/locale.c. I think they are related to a wrong configuration of IM during the previous step. Since I think I am not gonna need locale support, I hacked some things here to compile the library.
(1)
magick/locale.c:96:3: error: unknown type name 'locale_t'
magick/locale.c:96:15: error: 'locale_t' undeclared here (not in a function)

I simply fixed this by adding "typedef void* locale_t;"
(2)
magick/locale.c: In function 'AcquireCLocale':
magick/locale.c:135:5: warning: implicit declaration of function 'newlocale' [-Wimplicit-function-declaration]
magick/locale.c:135:24: error: 'LC_ALL_MASK' undeclared (first use in this function)

I fixed this by simply commenting it out.

I was able to compile the library, but I got several more warnings:
magick/locale.c: In function 'DestroyCLocale':
magick/locale.c:168:5: warning: implicit declaration of function 'freelocale' [-Wimplicit-function-declaration]
magick/locale.c: In function 'FormatLocaleFileList':
magick/locale.c:258:7: warning: implicit declaration of function 'vfprintf_l' [-Wimplicit-function-declaration]
magick/locale.c: In function 'FormatLocaleStringList':
magick/locale.c:349:7: warning: implicit declaration of function 'vsnprintf_l' [-Wimplicit-function-declaration]
magick/locale.c: In function 'InterpretLocaleValue':
magick/locale.c:902:9: warning: implicit declaration of function 'strtod_l' [-Wimplicit-function-declaration]
magick/utility.c: In function 'GetExecutionPath':
magick/utility.c:1013:5: warning: implicit declaration of function '_NSGetExecutablePath' [-Wimplicit-function-declaration]
magick/utility.c:1023:5: warning: implicit declaration of function 'getexecname' [-Wimplicit-function-declaration]


I then started my Blackberry cascades project and tried calling

Code: Select all

Magick::InitializeMagick( *argv );
The linker then complains about missing references to all the functions above, where I got these 'implicit declarations'-warnings.
Ok, dirty fix again: uncomment the lines, return 0 or MagickFalse in the functions ... just to see weather it works or not.

Tada :) compiles and runs. Loading images is done and works fine.

Code: Select all

Magick::Image image;
QString target = QDir::currentPath() + "/app/native/assets/result.png";
QString source = QDir::currentPath() + "/app/native/assets/icon.png";
image.read( source.toStdString() );
image.write( target.toStdString() );
image_view->setImageSource( QUrl("asset:///result.png") );
Well, trying to load a pdf with

Code: Select all

QString source = QDir::currentPath() + "/app/native/assets/test.pdf";
image.read( source.toStdString() );
throws an exception. I am not able to tell you the content, because

Code: Select all

catch( Magick::Exception &e )
{
	std::cout << "Exception " << e.what() << std::endl;
}
only shows a blank string.

So, I read about ghostscript and that it is required to read PDFs. I cannot install ghostscript on the phone, hence I have to build it into a library - maybe I can build it into the IM library. From the output of configure I can see, that there are some problems with ghostscript:
checking for Ghostscript...
checking ghostscript/iapi.h usability... no
checking ghostscript/iapi.h presence... no
checking for ghostscript/iapi.h... no
checking ghostscript/ierrors.h usability... no
checking ghostscript/ierrors.h presence... no
checking for ghostscript/ierrors.h... no
checking for gsapi_new_instance in Ghostscript framework... no
checking for gsapi_new_instance in -lgs... no
checking if Ghostscript package is complete... no


Ok, pretty long problem, simple questions:
(1) How do I have to configure IM to be able to call 'make' without any dirty hacks in the code?
(2) Can you help me with opening PDF files (they will required a password, if that matters)?

Any help appreciated. Thanks in advance.
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: Compiling for arm-qnx and reading pdfs

Post by magick »

The configure script checks for certain functions such as newlocale() and strtod_l() and only utilizes the method if they are found. The 'implicit declaration' warnign is thrown if newlocale() is found but is not properly declared in the header file, typically locale.h. Check your system headers. Can you discover where newlocale() is defined?

With Ghostscript, you'll need to download the library and build it with the BlackBerry SDK. Next set the CFLAGS and LDFLAGS environment variable to include the Ghostscript path. Finally, add --with-gslib to the ImageMagick configure script command line to enable Ghostscript library support.
stefan_a
Posts: 3
Joined: 2013-03-04T01:09:22-07:00
Authentication code: 6789

Re: Compiling for arm-qnx and reading pdfs

Post by stefan_a »

Just a short info: I cannot find 'newlocale' or 'strtod_l' defined anywhere in the entire Blackberry SDK (that's where I would search for the system headers).
Thanks so far. I will try to compile Ghostscript.
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: Compiling for arm-qnx and reading pdfs

Post by magick »

Check config.log and look for 'newlocale'. The configure script is supposed to define MAGICKCORE_HAVE_NEWLOCALE in magick/magick-baseconfg.h if it finds it defined in one of the system headers.
stefan_a
Posts: 3
Joined: 2013-03-04T01:09:22-07:00
Authentication code: 6789

Re: Compiling for arm-qnx and reading pdfs

Post by stefan_a »

I think I am not looking at the right position, because I can only find these two segments inside of config.log:

Code: Select all

  configure:25140: checking for newlocale
configure:25140: qcc -V4.6.3,gcc_ntoarmv7le -o conftest   -fPIC -Wall  -DMAGICKCORE_HDRI_ENABLE=0 -DMAGICKCORE_QUANTUM_DEPTH=8  -DMAGICKCORE_HDRI_ENABLE=0 -DMAGICKCORE_QUANTUM_DEPTH=8  conftest.c -lm  -lsocket >&5
configure:25140: $? = 0
configure:25140: result: yes
and later

Code: Select all

ac_cv_func_newlocale=yes
Then, MAGICKCORE_HAVE_NEWLOCALE is set to 1 in magick-baseconfig.h

btw: I did not managed to compile ghostscript for that environment for now and have to look for an alternative anyway, since I most likely cannot use GPL. Nevertheless, I might use IM in other projects.
Post Reply