Compiling for arm-qnx and reading pdfs
Posted: 2013-03-04T02:00:31-07:00
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
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.
Well, trying to load a pdf with
throws an exception. I am not able to tell you the content, because
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.
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 );
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") );
Code: Select all
QString source = QDir::currentPath() + "/app/native/assets/test.pdf";
image.read( source.toStdString() );
Code: Select all
catch( Magick::Exception &e )
{
std::cout << "Exception " << e.what() << std::endl;
}
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.