Termux-packages: Trying to build new package (libgirepository)

Created on 27 Jun 2018  路  4Comments  路  Source: termux/termux-packages

In an attempt to build libgirepository (with the goal to use python gobject introspection), the build script is failing to run configure failing with:

checking for a Python interpreter with version >= 2.7... python
checking for python... /usr/bin/python
checking for python version... 2.7
checking for python platform... linux2
checking for python script directory... ${prefix}/lib/python2.7/site-packages
checking for python extension module directory... ${exec_prefix}/lib/python2.7/site-packages
checking for headers required to compile python extensions... /home/builder/.termux-build/libgirepository/src/configure: line 15236: /usr/bin/python-config: No such file or directory
not found
configure: error: Python headers not found

Any tips on how to proceed?

help wanted question

All 4 comments

@romaia It seems as it picks up the host python, not the cross compiled one. I'm not sure how the build works here, but have a look at how e.g. the asciinema package does the following

termux_step_make_install () {
    export PYTHONPATH=$TERMUX_PREFIX/lib/python3.6/site-packages/
    python3.6 setup.py install --prefix=$TERMUX_PREFIX --force
}

What is the source url for the tarball you're building?

I have managed to progress a bit, by setting CPPFLAGS in termux_step_pre_configure and a little patch for one of the c source files.

The compilation produces a lot of warnings, but does compile.

But, looks like the build process tries to execute some of the binaries produced, as this is what fails:

./g-ir-compiler: line 117: /home/builder/.termux-build/libgirepository/build/.libs/g-ir-compiler: cannot execute binary file: Exec format error
./g-ir-compiler: line 117: /home/builder/.termux-build/libgirepository/build/.libs/g-ir-compiler: Success
./g-ir-compiler: line 117: /home/builder/.termux-build/libgirepository/build/.libs/g-ir-compiler: cannot execute binary file: Exec format error
./g-ir-compiler: line 117: /home/builder/.termux-build/libgirepository/build/.libs/g-ir-compiler: Success
Makefile:3789: recipe for target 'gir/freetype2-2.0.typelib' failed
make[2]: *** [gir/freetype2-2.0.typelib] Error 126
make[2]: *** Waiting for unfinished jobs....
Makefile:3789: recipe for target 'gir/fontconfig-2.0.typelib' failed
make[2]: *** [gir/fontconfig-2.0.typelib] Error 126
./g-ir-compiler: line 117: /home/builder/.termux-build/libgirepository/build/.libs/g-ir-compiler: cannot execute binary file: Exec format error
./g-ir-compiler: line 117: /home/builder/.termux-build/libgirepository/build/.libs/g-ir-compiler: Success
Makefile:3789: recipe for target 'gir/DBus-1.0.typelib' failed
make[2]: *** [gir/DBus-1.0.typelib] Error 126
Traceback (most recent call last):
  File "./g-ir-scanner", line 65, in <module>
    from giscanner.scannermain import scanner_main
  File "/home/builder/.termux-build/libgirepository/src/giscanner/scannermain.py", line 41, in <module>
    from giscanner.dumper import compile_introspection_binary
  File "/home/builder/.termux-build/libgirepository/src/giscanner/dumper.py", line 35, in <module>
    from .gdumpparser import IntrospectionBinary
  File "/home/builder/.termux-build/libgirepository/src/giscanner/gdumpparser.py", line 36, in <module>
    from .transformer import TransformerException
  File "/home/builder/.termux-build/libgirepository/src/giscanner/transformer.py", line 34, in <module>
    from .girparser import GIRParser
  File "/home/builder/.termux-build/libgirepository/src/giscanner/girparser.py", line 31, in <module>
    from .girwriter import COMPATIBLE_GIR_VERSION
  File "/home/builder/.termux-build/libgirepository/src/giscanner/girwriter.py", line 29, in <module>
    from .xmlwriter import XMLWriter
  File "/home/builder/.termux-build/libgirepository/src/giscanner/xmlwriter.py", line 44, in <module>
    from _giscanner import collect_attributes
  File "/home/builder/.termux-build/libgirepository/src/giscanner/libtoolimporter.py", line 68, in load_module
    mod = imp.load_module(name, open(realpath), realpath, suffix)
ImportError: /home/builder/.termux-build/libgirepository/build/.libs/_giscanner.so: wrong ELF class: ELFCLASS32
Makefile:3776: recipe for target 'GLib-2.0.gir' failed

I have found [1] some [2] reference [3] on cross compiling this, and will investigate this further.

[1] https://bugzilla.gnome.org/show_bug.cgi?id=696773
[2] https://gitlab.gnome.org/GNOME/gobject-introspection/commit/b638438e874fa437adff3bb0480710fe5cbe120c
[3] http://nicola.entidi.com/post/cross-compiling-gobject-introspection/?commentsstart7=70

Current wip patch is at https://hastebin.com/isemumevus.diff

Initial thoughts:

  • You don't need to set TERMUX_PKG_REVISION=1
  • You can omit TERMUX_PKG_EXTRA_CONFIGURE_ARGS if you think it isn't needed.
  • You can use termux_step_host_build () {...} to build stuff that needs to be run during compilation. python-dev and libffi-dev are needed for the ./configure step to work.

Did you eventually manage to get this to build and if so please can you provide the steps that worked?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

StephanBeer picture StephanBeer  路  3Comments

reggi picture reggi  路  4Comments

adit picture adit  路  3Comments

neitsab picture neitsab  路  3Comments

jackbrycesmith picture jackbrycesmith  路  3Comments