[xsde-users] Bug?

Laurent Michel laurent1984 at gmail.com
Sat Feb 18 10:56:50 EST 2017


Dear xsd/e support,

My objective is to be able to run my application on an android device. My
application makes use of XSD validation / XML data reading.

My first shot was to use the XSD library, but, for some reason I don't
really understand, it doesn't work. I cross-compiled icu and xerces-c for
the target architecture (I tried android-x86 and android-aarch64) and as
soon as I'm trying to construct an object of the type I am defining in my
xsd schemes, the application crashes. In a debug session, I was able to see
that the problem was the following: I have an XSD class

class Action: public ::xml_schema::type
{
  public:
  [...]
  typedef ::xml_schema::string title_type;
  [...]
  Action (const title_type&);
  [...]
}

And the application crashes under Android whenever I call something like

Action("");

or

Action("myString");

It also crashes if I call

auto tmp = ::xml_schema::string("hahaha");

It works, however, perfectly fine under my Ubuntu distro, it worked also
fine under Windows 10. What I don't really understand is, that I only link
against icu and xerces-c and I only include the xsd header files during
compilation, be it for windows 10, Ubuntu, or android. So, there can't be
any problem with xsd... but apparently I have one, which is what I
don't understand. Maybe you guys know incidentally what can go wrong in my
case when I then want to use XSD on android.

Here's how I compile icu:

https://github.com/zadigus/BrainReliefer/blob/master/config/cross-compilation/icu/compileAll.sh

Here's how I compile xerces-c:

https://github.com/zadigus/BrainReliefer/blob/master/config/cross-compilation/xerces-c/compileAll.sh

I tried to use XSD's last version (4.0.0). In order to make this work, I
guess I need to cross-compile XSD too ... but there is nowhere an advice
that I should do it like this.

Because XSD didn't work for me, I tried to switch to XSD/e, which would be
a good idea anyway because it is a lightweight library and this is what
people are usually looking for when they are programming mobile apps.

Here's how I cross-compile XSD/e:

https://github.com/zadigus/BrainReliefer/blob/master/config/cross-compilation/xsde/compile.sh

Alright. This script lets me cross-compile XSD/e up to one point (and it is
not using any of the etc/android stuff as recommended, sorry, I am not used
to compile my code with these *.mk files which I absolutely don't
understand...): if I do this:

make CXXFLAGS="$CXXFLAGS" CPPFLAGS="$CPPFLAGS" LDFLAGS="$LDFLAGS" CC="$CC"
CXX="$CXX" AR="$AR" RANLIB="$RANLIB"

where all the variables are well-defined, then I notice that (at least) the
AR and RANLIB variables are not set by the values I chose for them, i.e.
every time I compiled my code, whatever RANLIB or AR are, make used the
default /usr/bin/ar and /usr/bin/ranlib executables. This is not the case
for the other variables. My fix for this issue was simply to update the
file

~/Downloads/xsde/xsde/build/ld/configuration-lib-dynamic.make

from this

ld_lib_type   := archive
ld_lib_ar     := ar
ld_lib_ranlib := ranlib

to this

ld_lib_type   := archive
ld_lib_ar     := $(AR)
ld_lib_ranlib := $(RANLIB)

And now, make is using what I told it to use ...

However, this fix may not be philosophically compatible with what you are
doing, I don't know. Maybe the way I am cross-compiling XSD/e is wrong, no
idea. All I know is that I have now a static library which seems to be
compatible with my android architecture. I haven't tested linking my
application against this cross-compiled xsd/e yet. The way I compiled XSD/e
is the very same way I compiled Qt, boost, icu, and xerces-c.

Maybe it's fine to use the /usr/bin/ranlib and /usr/bin/ar. I saw that
these binaries are somehow compatible with android...

Thank your in advance for your advice,

Laurent


More information about the xsde-users mailing list