MapServer going mobile on Zaurus

blaise bpicinbono at WORLDONLINE.FR
Thu Mar 24 23:32:15 EST 2005


Hi,
I would have like to post this on the devel list but I can't. (I'm often lost
with sucribtion proccess...sorry)

Well, I hope I'm close to it. I got a Zaurus sl-5500 recently to try to put
MapServer inside.
Very nooB with mobile devices, it has been difficult to start. Installing and
compiling on these little machines is not set up out of the box. I've heard
about cross-compilation, that I'll use when I'll be sure MapServer runs fine,
but I focussed on native compilation. There are various distros, various
compilation tools and various gcc versions; I don't get it all yet.
I am using the OpenZaurus-3.5.2 distro , with OPIE-1.2 flavour. I had
difficulties to get a compiler compiles, finally, I did it with the zgcc
compilation tool that runs with gcc-2.95.2.
I think I've been able to (quite easy, with ipk (kind of rpm)) install some
required graphic libs and their devel (libfreetype, zlib, libpng, libjpeg).
With links and nice ./configure flags :

./configure --without-tiff --with-freetype=/usr/lib --with-zlib=/usr/lib
--with-png=/usr/lib --with-jpeg=/usr/lib --with-gd=/usr

 MapServer finds the libs at configure and build time. I am still missing the
libtiff devel package, but I should get it or I will try to build it.
The configure pass seems to go smoothly, I can join the output if needed; but
I get a strange kind of errors at build :

./libmap.a(mapstring.o): In function 'trimLeft':
mapstring.o(.text+0x258): undefined reference to '__ctype_b'
./libmap.a(mapstring.o): In function 'MSEncodeUrl':
mapstring.o(.text+0x98c): undefined reference to '__ctype_b'
./libmap.a(mapstring.o): In function 'hash':
maphash.o(.text+0x98): undefined reference to '__ctype_tolower'
collect2: ld returned 1 exit status
make: *** [shp2img] Error 1

I am not compiling often, except MapServer and graphic libs, and I don't think
I have seen this kind of error before with MapServer. What about you ?

I wonder if it could be related to the gcc-2.95.2 that runs on the Zaurus.
What gcc version is MapServer code compatible ?
I am investigating, maybe also a missing package (c++ ? libstdc++ ? else ?),
or missing links, bad pathes (as Zaurus as a specific file tree, plenty of
links) ? Or missing flags to the ./configure ?

The files concerned seems to be mapstring.c and maphash.c. I started to cut in
the functions implicated (knowing I was a bit destroying MapServer) to see if
it could build up to the end, but as I suppressed some errors, new ones of
the same kind appeared elsewhere....

So I am looking into MapServer code and googling, but as I haven't C coded for
a long time, I am a bit lost with the syntax. Following are the three
functions that rise the build errors. If a skilled C anthropologist can see a
reason why gcc-2.95.2 can't cope with them.
( I am testing with MapServer-4.4.1. As the Zaurus systems seem to be one step
before (kernel 2.4...) , would it be worth to try with a 3.6.x MapServer
version (about the C code) ? )
Of course, when I'll have it work, I will be glad to share the process and add
a stone to the supported processors list. MapServer on mobile can be for fun,
but also much more, I think, with gps and wifi...

So here are the three functions that I suspect to kill the build :

---------------------------------------------------------------------------------------------------
File : "mapstring.c", lines 207-242, function (?) trimLeft :
---------------------------------------------------------------------------------------------------
/**
 * remove leading white spaces and shif evey thing to the left
 */

char *trimLeft(char *string)
{
    char *read, *write;
    int i, length;

    if (string && strlen(string) > 0)
    {
        length = strlen(string);
        read = string;
        write = string;

        for (i=0; i<length; i++)
        {
            if (isspace(string[i]))
              read++;
            else
              break;
        }

        if (read > write)
        {
            while (*read)
            {
                *write = *read;
                read++;
                write++;
            }
            *write = '\0';
        }
    }
    return string;
}




-------------------------------------------------------------------------------------------------------------
File : "mapstring.c", lines 569-602, function (?) msEncodeUrl :
-------------------------------------------------------------------------------------------------------------
char *msEncodeUrl(const char *data)
{
  char *hex = "0123456789ABCDEF";
  const char *i;
  char  *j, *code;
  int   inc;
  unsigned char ch;

  for (inc=0, i=data; *i!='\0'; i++)
    if (!isalnum(*i))
      inc += 2;

  if (!(code = (char*)malloc(strlen(data)+inc+1)))
    return NULL;

  for (j=code, i=data; *i!='\0'; i++, j++)
    {
      if (*i == ' ')
        *j = '+';
      else
      if (!isalnum(*i))
        {
          ch = *i;
          *j++ = '%';
          *j++ = hex[ch/16];
          *j   = hex[ch%16];
        }
      else
        *j = *i;
    }
  *j = '\0';

  return code;
}



----------------------------------------------------------------------------------------
File : "maphash.c", lines 45-53, function (?) hash :
----------------------------------------------------------------------------------------
static unsigned hash(const char *key)
{
  unsigned hashval;

  for(hashval=0; *key!='\0'; key++)
    hashval = tolower(*key) + 31 * hashval;

  return(hashval % MS_HASHSIZE);
}



Thks
Blaise



More information about the mapserver-users mailing list