Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cross compile crash. RPi. #49

Open
ivlevdenis opened this issue Sep 7, 2016 · 0 comments
Open

Cross compile crash. RPi. #49

ivlevdenis opened this issue Sep 7, 2016 · 0 comments

Comments

@ivlevdenis
Copy link

ivlevdenis commented Sep 7, 2016

I'm testing cross compile this lib for Raspberry Pi 2.

  1. Mount RPi rootfs to /mnt/rasp-pi-rootfs/. Create symlink in /usr/local to /mnt/rasp-pi-rootfs/usr/local/QtDIR.
  2. Create simple test bin with cargo new hello --bin and add qmlrs to dependencies.
  3. Add target to ~/.cargo/config
[target.armv7-unknown-linux-gnueabihf]
linker = "/mnt/rasp-pi-rootfs/usr/bin/arm-linux-gnueabihf-gcc"
  1. First run cargo build --target=armv7-unknown-linux-gnueabihf for fetch dependencies.
  2. Add
set(CMAKE_SYSTEM_NAME Linux)
set(CMAKE_SYSROOT /mnt/rasp-pi-rootfs)
set(CMAKE_C_COMPILER /home/di-erz/projects/images/gcc-4.7-linaro-rpi-gnueabihf/bin/arm-linux-gnueabihf-gcc)
set(CMAKE_CXX_COMPILER /home/di-erz/projects/images/gcc-4.7-linaro-rpi-gnueabihf/bin/arm-linux-gnueabihf-g++)
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY)

to CMakeLists.txt to qmlrs-0.1.1/ext/libqmlrswrapper.
Then build static libqmlrswrapper

$ cd qmlrs-0.1.1/ext/libqmlrswrapper/build

$ PATH=$PATH:/mnt/rasp-pi-rootfs/usr/local/Qt-rasp2-5.7.0 \
LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/mnt/rasp-pi-rootfs/usr/local/Qt-rasp2-5.7.0/lib \
PKG_CONFIG_PATH=$PKG_CONFIG_PATH:/mnt/rasp-pi-rootfs/usr/local/Qt-rasp2-5.7.0/lib/pkgconfig/ \
CMAKE_SYSROOT=/mnt/rasp-pi-rootfs/ \
CMAKE_CXX_COMPILER=/mnt/rasp-pi-rootfs/usr/bin/arm-linux-gnueabihf-cpp \
CMAKE_C_COMPILER=/mnt/rasp-pi-rootfs/usr/bin/arm-linux-gnueabihf-gcc \
cmake ../

$ make
  1. Return to test project dir, clean, and rebuild.
$ cd projects/hello

$ CMAKE_SYSROOT=/mnt/rasp-pi-rootfs \
PATH=/mnt/rasp-pi-rootfs/usr/local/Qt-rasp2-5.7.0:$PATH \
PKG_CONFIG_PATH=/mnt/rasp-pi-rootfs/usr/local/Qt-rasp2-5.7.0/lib/pkgconfig/ \
PKG_CONFIG_ALLOW_CROSS=1 \
cargo build --target=armv7-unknown-linux-gnueabihf --verbose

Cargo exit with 101 error code.

   Compiling hello v0.1.0 (file:///home/di-erz/projects/rust_test_armf7/hello)
     Running `rustc src/main.rs --crate-name hello --crate-type bin -g -C metadata=633f842f00664fda --out-dir /home/di-erz/projects/rust_test_armf7/hello/target/armv7-unknown-linux-gnueabihf/debug --emit=dep-info,link --target armv7-unknown-linux-gnueabihf -C linker=/mnt/rasp-pi-rootfs/usr/bin/arm-linux-gnueabihf-gcc -L dependency=/home/di-erz/projects/rust_test_armf7/hello/target/armv7-unknown-linux-gnueabihf/debug/deps --extern qmlrs=/home/di-erz/projects/rust_test_armf7/hello/target/armv7-unknown-linux-gnueabihf/debug/deps/libqmlrs-4c95d386a3275de2.rlib -L native=/home/di-erz/.cargo/registry/src/github.com-1ecc6299db9ec823/qmlrs-0.1.1/ext/libqmlrswrapper/build -L native=/usr/local/Qt-rasp2-5.7.0/lib`
error: linking with `/mnt/rasp-pi-rootfs/usr/bin/arm-linux-gnueabihf-gcc` failed: exit code: 2
  |
  = note: "/mnt/rasp-pi-rootfs/usr/bin/arm-linux-gnueabihf-gcc" "-Wl,--as-needed" "-Wl,-z,noexecstack" "-L" "/home/di-erz/.multirust/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/armv7-unknown-linux-gnueabihf/lib" "/home/di-erz/projects/rust_test_armf7/hello/target/armv7-unknown-linux-gnueabihf/debug/hello.0.o" "-o" "/home/di-erz/projects/rust_test_armf7/hello/target/armv7-unknown-linux-gnueabihf/debug/hello" "-Wl,--gc-sections" "-pie" "-nodefaultlibs" "-L" "/home/di-erz/projects/rust_test_armf7/hello/target/armv7-unknown-linux-gnueabihf/debug/deps" "-L" "/home/di-erz/.cargo/registry/src/github.com-1ecc6299db9ec823/qmlrs-0.1.1/ext/libqmlrswrapper/build" "-L" "/usr/local/Qt-rasp2-5.7.0/lib" "-L" "/home/di-erz/.multirust/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/armv7-unknown-linux-gnueabihf/lib" "-Wl,-Bstatic" "-Wl,-Bdynamic" "/home/di-erz/projects/rust_test_armf7/hello/target/armv7-unknown-linux-gnueabihf/debug/deps/libqmlrs-4c95d386a3275de2.rlib" "/home/di-erz/projects/rust_test_armf7/hello/target/armv7-unknown-linux-gnueabihf/debug/deps/liblibc-1bd8847afb79f283.rlib" "/home/di-erz/.multirust/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/armv7-unknown-linux-gnueabihf/lib/libstd-958ae23af751ccd2.rlib" "/home/di-erz/.multirust/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/armv7-unknown-linux-gnueabihf/lib/libpanic_unwind-a9a59c59600d7fc2.rlib" "/home/di-erz/.multirust/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/armv7-unknown-linux-gnueabihf/lib/libunwind-6c9d51e4a80592ac.rlib" "/home/di-erz/.multirust/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/armv7-unknown-linux-gnueabihf/lib/libcollections-d6fc9dbb93241229.rlib" "/home/di-erz/.multirust/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/armv7-unknown-linux-gnueabihf/lib/liballoc-d486feb737ebb44c.rlib" "/home/di-erz/.multirust/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/armv7-unknown-linux-gnueabihf/lib/liballoc_jemalloc-ffb42151b6c9616e.rlib" "/home/di-erz/.multirust/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/armv7-unknown-linux-gnueabihf/lib/liblibc-233ca0904a4b2a29.rlib" "/home/di-erz/.multirust/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/armv7-unknown-linux-gnueabihf/lib/librand-2bb4926cb0753fd8.rlib" "/home/di-erz/.multirust/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/armv7-unknown-linux-gnueabihf/lib/librustc_unicode-ccb09dfcfc8f1ea6.rlib" "/home/di-erz/.multirust/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/armv7-unknown-linux-gnueabihf/lib/libcore-aad7393ea968a91e.rlib" "-l" "stdc++" "-l" "Qt5Quick" "-l" "Qt5Gui" "-l" "Qt5Qml" "-l" "Qt5Network" "-l" "Qt5Core" "-l" "util" "-l" "dl" "-l" "rt" "-l" "pthread" "-l" "gcc_s" "-l" "pthread" "-l" "c" "-l" "m" "-l" "rt" "-l" "util" "-l" "compiler-rt"
  = note: /mnt/rasp-pi-rootfs/usr/bin/arm-linux-gnueabihf-gcc: 1: /mnt/rasp-pi-rootfs/usr/bin/arm-linux-gnueabihf-gcc: Syntax error: word unexpected (expecting ")")


error: aborting due to previous error

error: Could not compile `hello`.

Caused by:
  Process didn't exit successfully: `rustc src/main.rs --crate-name hello --crate-type bin -g -C metadata=633f842f00664fda --out-dir /home/di-erz/projects/rust_test_armf7/hello/target/armv7-unknown-linux-gnueabihf/debug --emit=dep-info,link --target armv7-unknown-linux-gnueabihf -C linker=/mnt/rasp-pi-rootfs/usr/bin/arm-linux-gnueabihf-gcc -L dependency=/home/di-erz/projects/rust_test_armf7/hello/target/armv7-unknown-linux-gnueabihf/debug/deps --extern qmlrs=/home/di-erz/projects/rust_test_armf7/hello/target/armv7-unknown-linux-gnueabihf/debug/deps/libqmlrs-4c95d386a3275de2.rlib -L native=/home/di-erz/.cargo/registry/src/github.com-1ecc6299db9ec823/qmlrs-0.1.1/ext/libqmlrswrapper/build -L native=/usr/local/Qt-rasp2-5.7.0/lib` (exit code: 101)

I would be glad of any idea!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant