datachannel-rs: Cross compiling fails for armv7 / Raspberry PI target

I’m trying to release my project for the Raspberry Pi but cross compiling appears to be somehow misconfigured for datachannel-sys specifically. Any idea how to fix this?

Steps to Reproduce

  1. Add a target for armv7 rustup target add armv7-unknown-linux-gnueabihf
  2. Set the appropriate linker in your .cargo/config:
[target.armv7-unknown-linux-gnueabihf]
linker = "arm-linux-gnueabihf-gcc"
  1. cargo build --target=armv7-unknown-linux-gnueabihf

Output

   Compiling datachannel-sys v0.10.4 (https://github.com/lerouxrgd/datachannel-rs.git?branch=renaming#b243b29b)
   Compiling prost v0.6.1
   Compiling prost-types v0.6.1
   Compiling hyper v0.14.4
error: failed to run custom build command for `datachannel-sys v0.10.4 (https://github.com/lerouxrgd/datachannel-rs.git?branch=renaming#b243b29b)`

Caused by:
  process didn't exit successfully: `/home/user/teg/target/debug/build/datachannel-sys-6c67f118ca3f3589/build-script-build` (exit code: 101)
  --- stdout
  running: "cmake" "/home/user/.cargo/git/checkouts/datachannel-rs-53818dc2b1b154f1/b243b29/datachannel-sys/libdatachannel" "-DNO_WEBSOCKET=ON" "-DNO_EXAMPLES=ON" "-DNO_MEDIA=ON" "-DCMAKE_INSTALL_PREFIX=/home/user/teg/target/armv7-unknown-linux-gnueabihf/debug/build/datachannel-sys-71f67018426d7a71/out" "-DCMAKE_C_FLAGS= -ffunction-sections -fdata-sections -fPIC -march=armv7-a" "-DCMAKE_C_COMPILER=/usr/bin/arm-linux-gnueabihf-gcc" "-DCMAKE_CXX_FLAGS= -ffunction-sections -fdata-sections -fPIC -march=armv7-a" "-DCMAKE_CXX_COMPILER=arm-linux-gnueabihf-g++" "-DCMAKE_ASM_FLAGS= -ffunction-sections -fdata-sections -fPIC -march=armv7-a" "-DCMAKE_ASM_COMPILER=/usr/bin/arm-linux-gnueabihf-gcc" "-DCMAKE_BUILD_TYPE=Debug"
  -- The CXX compiler identification is unknown
  -- Configuring incomplete, errors occurred!
  See also "/home/user/teg/target/armv7-unknown-linux-gnueabihf/debug/build/datachannel-sys-71f67018426d7a71/out/build/CMakeFiles/CMakeOutput.log".
  See also "/home/user/teg/target/armv7-unknown-linux-gnueabihf/debug/build/datachannel-sys-71f67018426d7a71/out/build/CMakeFiles/CMakeError.log".

  --- stderr
  CMake Error at CMakeLists.txt:2 (project):
    The CMAKE_CXX_COMPILER:

      arm-linux-gnueabihf-g++

    is not a full path and was not found in the PATH.

    Tell CMake where to find the compiler by setting either the environment
    variable "CXX" or the CMake cache entry CMAKE_CXX_COMPILER to the full path
    to the compiler, or to the compiler name if it is in the PATH.


  thread 'main' panicked at '
  command did not execute successfully, got: exit code: 1

  build script failed, must exit now', /home/user/.cargo/registry/src/github.com-1ecc6299db9ec823/cmake-0.1.45/src/lib.rs:894:5
  note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
warning: build failed, waiting for other jobs to finish...
error: build failed

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Comments: 33 (11 by maintainers)

Most upvoted comments

Ah interesting, I might come back to that in future. For now though it’s running happily on the Raspberry Pi in a Snap container which brings a nice, up to date gcc with it. Thanks for all the help on this one - really appreciate it!

Wow! Yeah, I just cross-compiled the rest of my project! The static-openssl branch works - thanks so much!!

@lerouxrgd Looks like it worked:

[100%] Linking CXX static library libdatachannel-static.a
[100%] Built target datachannel-static