• Willkommen im Linux Club - dem deutschsprachigen Supportforum für GNU/Linux. Registriere dich kostenlos, um alle Inhalte zu sehen und Fragen zu stellen.

[gelöst] libxml2 für Intel Xscale

Phillinger

Member
Salve,

auf meiner Embedded Zielplattform läuft ein Intel Xscale (ARM-Architektur). Für diese Plattform nutze ich einen Cross-Compiler. Nun möchte ich dieser Tool-Chain die XML-Bibliothek libxml2 hinzufügen. Dazu habe ich mir von http://xmlsoft.org die Quellen heruntergeladen.

Ich stehe hier allerdings wie der Ochse vorm Berg: Welche Schalter muss ich umstellen, damit er zum Compilieren der Bibliothek den Cross-Compiler nimmt? Wo lege ich das Installationsverzeichnis fest? Hat hier schon jemand Erfahrungen damit gemacht, Bibliotheken mit einem Cross-Compiler zu kompilieren?
 
OP
Phillinger

Phillinger

Member
Um es ein wenig zu präzisieren:

Nachdem man die Sources entpackt hat, führt man das configure-Skript aus. Hierfür gibt es diverse Schalterchen (./configure --help). Z.B. legt
Code:
./configure --prefix=/usr/local/mxscaleb/
das Installationsverzeichnis fest. Aber wie teile ich dem configure-Skript mit, daß es es hier mit einer fremden Zielplattform zu tun hat?
 
OP
Phillinger

Phillinger

Member
:D

Mja, so einfach ist das leider nicht.
Code:
Usage: ./configure [OPTION]... [VAR=VALUE]...

To assign environment variables (e.g., CC, CFLAGS...), specify them as
VAR=VALUE.  See below for descriptions of some of the useful variables.

Defaults for the options are specified in brackets.

Configuration:
  -h, --help              display this help and exit
      --help=short        display options specific to this package
      --help=recursive    display the short help of all the included packages
  -V, --version           display version information and exit
  -q, --quiet, --silent   do not print `checking...' messages
      --cache-file=FILE   cache test results in FILE [disabled]
  -C, --config-cache      alias for `--cache-file=config.cache'
  -n, --no-create         do not create output files
      --srcdir=DIR        find the sources in DIR [configure dir or `..']

Installation directories:
  --prefix=PREFIX         install architecture-independent files in PREFIX
                          [/usr/local]
  --exec-prefix=EPREFIX   install architecture-dependent files in EPREFIX
                          [PREFIX]

By default, `make install' will install all the files in
`/usr/local/bin', `/usr/local/lib' etc.  You can specify
an installation prefix other than `/usr/local' using `--prefix',
for instance `--prefix=$HOME'.

For better control, use the options below.

Fine tuning of the installation directories:
  --bindir=DIR           user executables [EPREFIX/bin]
  --sbindir=DIR          system admin executables [EPREFIX/sbin]
  --libexecdir=DIR       program executables [EPREFIX/libexec]
  --datadir=DIR          read-only architecture-independent data [PREFIX/share]
  --sysconfdir=DIR       read-only single-machine data [PREFIX/etc]
  --sharedstatedir=DIR   modifiable architecture-independent data [PREFIX/com]
  --localstatedir=DIR    modifiable single-machine data [PREFIX/var]
  --libdir=DIR           object code libraries [EPREFIX/lib]
  --includedir=DIR       C header files [PREFIX/include]
  --oldincludedir=DIR    C header files for non-gcc [/usr/include]
  --infodir=DIR          info documentation [PREFIX/info]
  --mandir=DIR           man documentation [PREFIX/man]

Program names:
  --program-prefix=PREFIX            prepend PREFIX to installed program names
  --program-suffix=SUFFIX            append SUFFIX to installed program names
  --program-transform-name=PROGRAM   run sed PROGRAM on installed program names

System types:
  --build=BUILD     configure for building on BUILD [guessed]
  --host=HOST       cross-compile to build programs to run on HOST [BUILD]

Optional Features:
  --disable-FEATURE       do not include FEATURE (same as --enable-FEATURE=no)
  --enable-FEATURE[=ARG]  include FEATURE [ARG=yes]
  --disable-dependency-tracking  speeds up one-time build
  --enable-dependency-tracking   do not reject slow dependency extractors
  --enable-shared[=PKGS]
                          build shared libraries [default=yes]
  --enable-static[=PKGS]
                          build static libraries [default=yes]
  --enable-fast-install[=PKGS]
                          optimize for fast installation [default=yes]
  --disable-libtool-lock  avoid locking (might break parallel builds)
 --enable-ipv6=yes/no enables compilation of IPv6 code

Optional Packages:
  --with-PACKAGE[=ARG]    use PACKAGE [ARG=yes]
  --without-PACKAGE       do not use PACKAGE (same as --with-PACKAGE=no)
  --with-gnu-ld           assume the C compiler uses GNU ld [default=no]
  --with-pic              try to use only PIC/non-PIC objects [default=use
                          both]
  --with-tags[=TAGS]
                          include additional configurations [automatic]
  --with-minimum          build a minimally sized library (off)
  --with-zlib[=DIR]       use libz in DIR
  --with-html-dir=path    path to base html directory, default
                          $datadir/doc/html
  --with-html-subdir=path directory used under html-dir, default
                          $PACKAGE-$VERSION/html
  --with-fexceptions      add GCC flag -fexceptions for C++ exceptions (off)
  --with-python[=DIR]     build Python bindings if found
  --with-readline=DIR     use readline in DIR
  --with-threads          add multithread support(on)
  --with-thread-alloc     add per-thread memory(off)
  --with-history          add history support to xmllint shell(off)
  --with-output           add the serialization support (on)
  --with-tree             add the DOM like tree manipulation APIs (on)
  --with-ftp              add the FTP support (on)
  --with-http             add the HTTP support (on)
  --with-legacy           add deprecated APIs for compatibility (on)
  --with-reader           add the xmlReader parsing interface (on)
  --with-pattern           add the xmlPattern selection interface (on)
  --with-writer           add the xmlWriter saving interface (on)
  --with-sax1             add the older SAX1 interface (on)
  --with-push             add the PUSH parser interfaces (on)
  --with-html             add the HTML support (on)
  --with-valid            add the DTD validation support (on)
  --with-catalog          add the Catalog support (on)
  --with-docbook          add Docbook SGML support (on)
  --with-xpath            add the XPATH support (on)
  --with-xptr             add the XPointer support (on)
  --with-c14n             add the Canonicalization support (on)
  --with-xinclude         add the XInclude support (on)
  --with-iconv[=DIR]      add ICONV support (on)
  --with-iso8859x         add ISO8859X support if no iconv (on)
  --with-schemas          add Relax-NG and experimental Schemas support (on)
  --with-regexps          add Regular Expressions support (on)
  --with-debug            add the debugging module (on)
  --with-mem-debug        add the memory debugging module (off)

Some influential environment variables:
  CC          C compiler command
  CFLAGS      C compiler flags
  LDFLAGS     linker flags, e.g. -L<lib dir> if you have libraries in a
              nonstandard directory <lib dir>
  CPPFLAGS    C/C++ preprocessor flags, e.g. -I<include dir> if you have
              headers in a nonstandard directory <include dir>
  CPP         C preprocessor
  CXX         C++ compiler command
  CXXFLAGS    C++ compiler flags
  CXXCPP      C++ preprocessor
  F77         Fortran 77 compiler command
  FFLAGS      Fortran 77 compiler flags

Use these variables to override the choices made by `configure' or to help
it to find libraries and programs with nonstandard names/locations.

Ich wüsste z.B. nicht, was ich bei --host eintragen soll. Hier nehme ich einfach das, was ich vom Cross-Compiler erfahre (mxscaleb-gcc -v).
Code:
Reading specs from /usr/local/mxscaleb/lib/gcc-lib/armv5b-linux/3.3.2/specs
Konfiguriert mit: ../gcc-3.3.2/configure --host=i386-linux --build=i386-linux --prefix=/usr/local/mxscaleb --program-prefix=mxscaleb- --target=armv5b-linux --enable-shared --enable-threads --enable-languages=c,c++ --nfp --without-fp --with-cpu=xscale --with-softfloat-support=internal --with-inhibit-libc
Thread model: posix
gcc-Version 3.3.2

Demnach heißt das Target "armv5b-linux". Aber was für das configure vom GCC gilt, gilt nicht zwangsweise für das configure von libxml2.

Dann müsste ich mit CC=mxscaleb-gcc mit Gewalt den korrekten Cross-compiler erzwingen. Ich würde das aber gerne vom Configure-Skript korrekt erkennen lassen, damit ich nicht irgendeinen anderen Schalter vergesse.
 
Prinzipiell hast Du zwei Möglichkeiten:

1) Du lässt ./configure mittels --host wissen, welche Zielplattform Du haben willst, und überlasst das Finden der Build-Tools dem ./configure-Skript.

Das ist die einzige mir bekannte "offizielle" Methode:
Code:
./configure --host=armv5b-linux
Nur mal so zur Info: Das autoconf-System ist voll von "Magie", wenn in diesem Fall "armv5b-linux" zum Beispiel falsch wäre, dann würde es den Namen selbst "berichtigen".

Hast Du es denn überhaupt mal ausprobiert? Mach das doch mal.

Irgendwie muss ./configure wissen, ob es crosskompilieren soll oder nicht, und für welche Zielplattform. Völlig automatisch geht es nicht, aber immerhin teilautomatisch, siehe oben.

2) Du gibst, wie von Dir schon vorgeschlagen, den Crosscompiler explizit an. Das reicht allerdings definitiv nicht aus, sondern wenn Du es so machst, musst Du alle Crossbuildtools explizit angeben, z.B. so:
Code:
export CC=armv5b-linux-gcc
export LD=armv5b-linux-ld
export AR=armv5b-linux-ar
export NM=armv5b-linux-nm
./configure
Diese Methode funktioniert meistens auch, ist aber nicht der "offizielle" Weg.

Völlig automatisch geht es allerdings definitiv nicht. Irgendeinen Anhaltspunkt muss das Buildsystem haben, sonst kann es nicht wissen, was es für Dich tun soll.
 
OP
Phillinger

Phillinger

Member
Ich habe jetzt einen kleinen Mix veranstaltet, der augenscheinlich funktioniert.
Code:
./configure --prefix=/usr/local/mxscaleb/ --exec-prefix=/usr/local/mxscaleb/bin/ --target=armv5b-linux --with-cpu=xscale CC=mxscaleb-gcc CXX=mxscaleb-g++ STRIP=mxscaleb-strip --host=armv5b-linux  --build=i386-linux

Damit habe ich zumindest erreicht, daß er die Sources mit dem richtigen Compiler compiliert und wohl auch die richtige Zielplattform nimmt. Also doppelt gemoppelt. Er hat allerdings die libxml2.a (usw.) in ein anderes Unterverzeichnis getan, aber das konnte ich noch von Hand verschieben.

Jedenfalls meckert der Linker nun nicht mehr, wenn ich "-lxml2" anhänge.

Danke für die Hinweise, ich hab' sie einfach mal frei heraus kombiniert. :) Ob's jetzt wirklich funktioniert kann ich erst sagen, wenn er die XML-Files liest und richtig interpretiert.
 
Oben