Hi!
When developing software for embedded systems it is very useful to be able to cross compile the software on the developers workstation or build server. I know that snapcraft can build packages for arm devices on arm hardware (or virtual arm hardware such as qemu).
The question is:
Is it possible to cross compile c/c++ software (thats what i have been trying without success) on na intel laptop with armhf as target. At least the cmake plugin says:
snapcraft build --target-arch=armhf
Setting target machine to 'armhf'
Traceback (most recent call last):
File "/usr/bin/snapcraft", line 11, in <module>
load_entry_point('snapcraft==2.34+17.10', 'console_scripts', 'snapcraft')()
File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 564, in load_entry_point
return get_distribution(dist).load_entry_point(group, name)
File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 2662, in load_entry_point
return ep.load()
File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 2316, in load
return self.resolve()
File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 2322, in resolve
module = __import__(self.module_name, fromlist=['__name__'], level=0)
File "/usr/lib/python3/dist-packages/snapcraft/cli/__main__.py", line 19, in <module>
run(prog_name='snapcraft')
File "/usr/lib/python3/dist-packages/click/core.py", line 722, in __call__
return self.main(*args, **kwargs)
File "/usr/lib/python3/dist-packages/click/core.py", line 697, in
main
rv = self.invoke(ctx)
File "/usr/lib/python3/dist-packages/click/core.py", line 1066, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File "/usr/lib/python3/dist-packages/click/core.py", line 895, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "/usr/lib/python3/dist-packages/click/core.py", line 535, in invoke
return callback(*args, **kwargs)
File "/usr/lib/python3/dist-packages/snapcraft/cli/lifecycle.py", line 79, in build
_execute('build', parts, **kwargs)
File "/usr/lib/python3/dist-packages/snapcraft/cli/lifecycle.py", line 31, in _execute
lifecycle.execute(command, project_options, parts)
File "/usr/lib/python3/dist-packages/snapcraft/internal/lifecycle.py", line 113, in execute
config = snapcraft.internal.load_config(project_options)
File "/usr/lib/python3/dist-packages/snapcraft/internal/project_loader/__init__.py", line 24, in load_config
return Config(project_options)
File "/usr/lib/python3/dist-packages/snapcraft/internal/project_loader/_config.py", line 124, in
__init__
snapcraft_yaml=self.snapcraft_yaml_path)
File "/usr/lib/python3/dist-packages/snapcraft/internal/project_loader/_parts_config.py", line 55, in __init__
self._process_parts()
File "/usr/lib/python3/dist-packages/snapcraft/internal/project_loader/_parts_config.py", line 85, in _process_parts
self.load_part(part_name, plugin_name, properties)
File "/usr/lib/python3/dist-packages/snapcraft/internal/project_loader/_parts_config.py", line 169, in load_part
definitions_schema=self._validator.definitions_schema)
File "/usr/lib/python3/dist-packages/snapcraft/internal/pluginhandler/_plugin_loader.py", line 78, in load_plugin
plugin.enable_cross_compilation()
File "/usr/lib/python3/dist-packages/snapcraft/_baseplugin.py", line 182, in enable_cross_compilation
'to a different target architecture'.format(self.name))
NotImplementedError: The plugin used by 'snapcraft-test-src' does not support cross-compiling to a different target architecture
My snapcraft.yaml file looks like this:
name: snapcraft-test-pkg
version: '0.0.1'
summary: A test package
description: |
The only purpose of the package is to test the snap build chain.
architectures:
- armhf
- x86_64
grade: devel
confinement: strict
apps:
snap-test-exec:
command: snap-test-exec
parts:
snapcraft-test-src:
plugin: cmake
configflags:
- -DCMAKE_INSTALL_PREFIX=/usr
source-type: git
source: https://github.com/malo-rte/snapcraft-test-src.git
build-packages:
- build-essential
- gcc-arm-linux-gnueabihf
prime:
- usr/bin
Any help or suggestions is appreciated.
Best regards,
Mats Loman