nerves-web-kiosk / webengine_kiosk

Qt WebEngine-based kiosk
Other
74 stars 14 forks source link

Build issue "scrub-otp-release.sh: ERROR: Unexpected executable format" #29

Closed benrom closed 3 years ago

benrom commented 3 years ago

Hi,

I ran into an issue building the project for RPi3 with nerves on MacOS. I started with a blank new nerves project and added the dependency (QT installation via brew was fine with correct PATH added).

Here's the error I got:

> mix firmware    

Nerves environment
  MIX_TARGET:   rpi3
  MIX_ENV:      dev

Compiling 2 files (.ex)
Generated kiosk app
|nerves_bootstrap| Building OTP Release...

* skipping runtime configuration (config/releases.exs not found)
* creating _build/rpi3_dev/rel/kiosk/releases/0.1.0/vm.args
Updating base firmware image with Erlang release...
scrub-otp-release.sh: ERROR: Unexpected executable format for '/Users/chris/tests/kiosk/_build/_nerves-tmp/rootfs-additions/srv/erlang/lib/webengine_kiosk-0.2.5/priv/kiosk'

Got:
 file:Mach-O 64-bit executable x86_64

Expecting:
 readelf:ARM;0x5000400, Version5 EABI, hard-float ABI

This file was compiled for the host or a different target and probably
will not work.

Check the following:

1. Are you using a path dependency in your mix deps? If so, run
   'mix clean' in that directory to avoid pulling in any of its
   build products.

2. Did you recently upgrade to Elixir 1.9 or Nerves 1.5?
   Nerves 1.5 adds support for Elixir 1.9 Releases and requires
   you to either add an Elixir 1.9 Release configuration or add
   Distillery as a dependency. Without this, the OTP binaries
   for your build machine will get included incorrectly and cause
   this error. See
   https://hexdocs.pm/nerves/updating-projects.html#updating-from-v1-4-to-v1-5

3. Did you recently upgrade or change your Nerves system? If so,
   try cleaning and rebuilding this project and its deps.

4. Are you building outside of Nerves' mix integration? If so,
   make sure that you've sourced 'nerves-env.sh'.

If you're still having trouble, please file an issue on Github
at https://github.com/nerves-project/nerves_system_br/issues.

** (Mix) Nerves encountered an error. %IO.Stream{device: :standard_io, line_or_bytes: :line, raw: true}

The _nerves-tmp did not exist at that location, but it might have been removed at the end of the script.

I followed the given checklist but it did not help.

The project dependencies:

Dependency            Current  Latest  Update possible  
nerves                1.6.3    1.6.3                    
nerves_pack           0.3.3    0.3.3                    
nerves_runtime        0.11.2   0.11.2                   
nerves_system_bbb     2.7.1    2.7.1                    
nerves_system_rpi     1.12.1   1.12.1                   
nerves_system_rpi0    1.12.1   1.12.1                   
nerves_system_rpi2    1.12.1   1.12.1                   
nerves_system_rpi3    1.12.1   1.12.1                   
nerves_system_rpi3a   1.12.1   1.12.1                   
nerves_system_rpi4    1.12.1   1.12.1                   
nerves_system_x86_64  1.12.1   1.12.1                   
ring_logger           0.8.0    0.8.0                    
shoehorn              0.6.0    0.6.0                    
toolshed              0.2.13   0.2.13                   
webengine_kiosk       0.2.5    0.2.5   

My build environment:

Erlang/OTP 23 [erts-11.0.3] [source] [64-bit] [smp:4:4] [ds:4:4:10] [async-threads:1] [hipe] [dtrace] Elixir 1.10.4 (compiled with Erlang/OTP 23)

nerves_bootstrap-1.8.1

QMake version 3.1 Using Qt version 5.15.0 in /usr/local/Cellar/qt/5.15.0/lib

Here are the steps to reproduce:

mix nerves.new kiosk
cd kiosk
~   edit mix.exs to add webengine_kiosk dependency   ~
export MIX_TARGET=rpi3
mix deps.get
mix compile
mix firmware

Thanks for any help!

mobileoverlord commented 3 years ago

This is likely due to having compiled the version for mac first and then switching targets. The webengine kiosk application likely needs to be updated to build in the _build directory instead of in the source directory. I suspect that if you were to clean the dependency and build it again with the target set that it would work successfully.

benrom commented 3 years ago

That was a super quick reply, cheers!

As you can see in my steps to reproduce, the target is set before the dependencies are fetched and compiled.

I've just tried again the following, to make sure:

mix deps.clean --all   
MIX_TARGET=rpi3 mix deps.get
MIX_TARGET=rpi3 mix deps.compile
MIX_TARGET=rpi3 mix firmware

I got the same error.

During the deps.compile step I can see the following:

==> webengine_kiosk
mkdir -p /Users/chris/tests/kiosk/_build/rpi3_dev/lib/webengine_kiosk/priv
cp -r assets/www /Users/chris/tests/kiosk/_build/rpi3_dev/lib/webengine_kiosk/priv
mkdir -p /Users/chris/tests/kiosk/_build/rpi3_dev/lib/webengine_kiosk/obj
cd /Users/chris/tests/kiosk/_build/rpi3_dev/lib/webengine_kiosk/obj && qmake /Users/chris/tests/kiosk/deps/webengine_kiosk//src/kiosk.pro
Info: creating stash file /Users/chris/tests/kiosk/_build/rpi3_dev/lib/webengine_kiosk/obj/.qmake.stash
/Applications/Xcode.app/Contents/Developer/usr/bin/make -j3 -C /Users/chris/tests/kiosk/_build/rpi3_dev/lib/webengine_kiosk/obj
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++ -c -pipe -stdlib=libc++ -O2 -std=gnu++11  -arch x86_64 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk -mmacosx-version-min=10.13 -Wall -Wextra -fPIC -DQT_NO_DEBUG -DQT_WEBENGINEWIDGETS_LIB -DQT_PRINTSUPPORT_LIB -DQT_WIDGETS_LIB -DQT_MULTIMEDIA_LIB -DQT_WEBENGINECORE_LIB -DQT_QUICK_LIB -DQT_GUI_LIB -DQT_QMLMODELS_LIB -DQT_WEBCHANNEL_LIB -DQT_QML_LIB -DQT_NETWORK_LIB -DQT_POSITIONING_LIB -DQT_CORE_LIB -I/Users/chris/tests/kiosk/deps/webengine_kiosk/src -I. -I/usr/local/Cellar/qt/5.15.0/lib/QtWebEngineWidgets.framework/Headers -I/usr/local/Cellar/qt/5.15.0/lib/QtPrintSupport.framework/Headers -I/usr/local/Cellar/qt/5.15.0/lib/QtWidgets.framework/Headers -I/usr/local/Cellar/qt/5.15.0/lib/QtMultimedia.framework/Headers -I/usr/local/Cellar/qt/5.15.0/lib/QtWebEngineCore.framework/Headers -I/usr/local/Cellar/qt/5.15.0/lib/QtQuick.framework/Headers -I/usr/local/Cellar/qt/5.15.0/lib/QtGui.framework/Headers -I/usr/local/Cellar/qt/5.15.0/lib/QtQmlModels.framework/Headers -I/usr/local/Cellar/qt/5.15.0/lib/QtWebChannel.framework/Headers -I/usr/local/Cellar/qt/5.15.0/lib/QtQml.framework/Headers -I/usr/local/Cellar/qt/5.15.0/lib/QtNetwork.framework/Headers -I/usr/local/Cellar/qt/5.15.0/lib/QtPositioning.framework/Headers -I/usr/local/Cellar/qt/5.15.0/lib/QtCore.framework/Headers -I. -I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk/System/Library/Frameworks/OpenGL.framework/Headers -I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk/System/Library/Frameworks/AGL.framework/Headers -I/usr/local/Cellar/qt/5.15.0/mkspecs/macx-clang -F/usr/local/Cellar/qt/5.15.0/lib -o main.o /Users/chris/tests/kiosk/deps/webengine_kiosk/src/main.cpp

So it looks like indeed it targeted the x86_64 platform (Mac). Is there something I'm missing there to compile for Pi?

pavels commented 3 years ago

This looks like you have wrong system image

Can you post your mix.exs?

Basically you should have this {:kiosk_system_rpi3, "~> 1.10.0", runtime: false, targets: :rpi3}, instead of {:nerves_system_rpi3, "~> 1.12", runtime: false, targets: :rpi3} in your mix.exs

benrom commented 3 years ago

Thanks @pavels ! That was the problem indeed. I ran into more issues after that (asdf / curl / openssl versions), but I got it to compile and to work in the end!

Basically this example project told me everything I needed to do to get started: https://github.com/nerves-web-kiosk/kiosk_system_rpi3/tree/main/example