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

Looks like none of C++ code generated is linked properly #1268

Open
BlueZeeKing opened this issue Sep 3, 2023 · 3 comments
Open

Looks like none of C++ code generated is linked properly #1268

BlueZeeKing opened this issue Sep 3, 2023 · 3 comments

Comments

@BlueZeeKing
Copy link

When running cargo build, I get the error message:

   Compiling ctre v0.1.0 (/Users/braydenzee/Desktop/robotrs/ctre)
warning: unused variable: `motor`
  --> ctre/src/main.rs:36:9
   |
36 |     let motor = ffi::new_VictorSPX(1);
   |         ^^^^^ help: if this is intentional, prefix it with an underscore: `_motor`
   |
   = note: `#[warn(unused_variables)]` on by default

error: linking with `arm-frc2023-linux-gnueabi-gcc` failed: exit status: 1
  |
  = note: LC_ALL="C" PATH="<MY PATH>" VSLANG="1033" "arm-frc2023-linux-gnueabi-gcc" "/var/folders/wg/qnccs2s93hq87y4v80s6dfdc0000gn/T/rustcMXlkXt/symbols.o" "/Users/braydenzee/Desktop/robotrs/target/arm-unknown-linux-gnueabi/debug/deps/ctre-780ae51c3efcc338.14zj3412z7hn0mq4.rcgu.o" "/Users/braydenzee/Desktop/robotrs/target/arm-unknown-linux-gnueabi/debug/deps/ctre-780ae51c3efcc338.1o2enzafrkhtj0xr.rcgu.o" "/Users/braydenzee/Desktop/robotrs/target/arm-unknown-linux-gnueabi/debug/deps/ctre-780ae51c3efcc338.1x6s0wz0jwzspqlo.rcgu.o" "/Users/braydenzee/Desktop/robotrs/target/arm-unknown-linux-gnueabi/debug/deps/ctre-780ae51c3efcc338.2629p3efs6y22dw3.rcgu.o" "/Users/braydenzee/Desktop/robotrs/target/arm-unknown-linux-gnueabi/debug/deps/ctre-780ae51c3efcc338.351r58jm1tus3hek.rcgu.o" "/Users/braydenzee/Desktop/robotrs/target/arm-unknown-linux-gnueabi/debug/deps/ctre-780ae51c3efcc338.3qp63jav4qoo4sqx.rcgu.o" "/Users/braydenzee/Desktop/robotrs/target/arm-unknown-linux-gnueabi/debug/deps/ctre-780ae51c3efcc338.47uhe5vft99u93un.rcgu.o" "/Users/braydenzee/Desktop/robotrs/target/arm-unknown-linux-gnueabi/debug/deps/ctre-780ae51c3efcc338.2thq35rbcx7h6414.rcgu.o" "-Wl,--as-needed" "-L" "/Users/braydenzee/Desktop/robotrs/target/arm-unknown-linux-gnueabi/debug/deps" "-L" "/Users/braydenzee/Desktop/robotrs/target/debug/deps" "-L" "/Users/braydenzee/Desktop/robotrs/target/arm-unknown-linux-gnueabi/debug/build/ctre-d654242bc31a2273/out/lib" "-L" "/Users/braydenzee/Desktop/robotrs/target/arm-unknown-linux-gnueabi/debug/build/ctre-d654242bc31a2273/out" "-L" "/Users/braydenzee/Desktop/robotrs/target/arm-unknown-linux-gnueabi/debug/build/cxx-97f482b489ef9637/out" "-L" "/Users/braydenzee/Desktop/robotrs/target/arm-unknown-linux-gnueabi/debug/build/link-cplusplus-106c66522b413248/out" "-L" "/Users/braydenzee/.rustup/toolchains/stable-aarch64-apple-darwin/lib/rustlib/arm-unknown-linux-gnueabi/lib" "-Wl,-Bstatic" "/Users/braydenzee/Desktop/robotrs/target/arm-unknown-linux-gnueabi/debug/deps/libcxx-cba368c3337febe2.rlib" "/Users/braydenzee/Desktop/robotrs/target/arm-unknown-linux-gnueabi/debug/deps/liblink_cplusplus-0de2200d69ca588c.rlib" "/Users/braydenzee/.rustup/toolchains/stable-aarch64-apple-darwin/lib/rustlib/arm-unknown-linux-gnueabi/lib/libstd-ae6c1ab5c02c448e.rlib" "/Users/braydenzee/.rustup/toolchains/stable-aarch64-apple-darwin/lib/rustlib/arm-unknown-linux-gnueabi/lib/libpanic_unwind-4efcc033e29e3a60.rlib" "/Users/braydenzee/.rustup/toolchains/stable-aarch64-apple-darwin/lib/rustlib/arm-unknown-linux-gnueabi/lib/libobject-84b151303bbd2cd1.rlib" "/Users/braydenzee/.rustup/toolchains/stable-aarch64-apple-darwin/lib/rustlib/arm-unknown-linux-gnueabi/lib/libmemchr-9f4c7a5ddeb7f6c9.rlib" "/Users/braydenzee/.rustup/toolchains/stable-aarch64-apple-darwin/lib/rustlib/arm-unknown-linux-gnueabi/lib/libaddr2line-dcd97406b7431b1e.rlib" "/Users/braydenzee/.rustup/toolchains/stable-aarch64-apple-darwin/lib/rustlib/arm-unknown-linux-gnueabi/lib/libgimli-be9185e9796719e2.rlib" "/Users/braydenzee/.rustup/toolchains/stable-aarch64-apple-darwin/lib/rustlib/arm-unknown-linux-gnueabi/lib/librustc_demangle-862301a10afbf865.rlib" "/Users/braydenzee/.rustup/toolchains/stable-aarch64-apple-darwin/lib/rustlib/arm-unknown-linux-gnueabi/lib/libstd_detect-e8cdac7dbe7c977e.rlib" "/Users/braydenzee/.rustup/toolchains/stable-aarch64-apple-darwin/lib/rustlib/arm-unknown-linux-gnueabi/lib/libhashbrown-5685716dc6e2099a.rlib" "/Users/braydenzee/.rustup/toolchains/stable-aarch64-apple-darwin/lib/rustlib/arm-unknown-linux-gnueabi/lib/librustc_std_workspace_alloc-aca6c7e4ac6ddd6f.rlib" "/Users/braydenzee/.rustup/toolchains/stable-aarch64-apple-darwin/lib/rustlib/arm-unknown-linux-gnueabi/lib/libminiz_oxide-6495e44664ebde64.rlib" "/Users/braydenzee/.rustup/toolchains/stable-aarch64-apple-darwin/lib/rustlib/arm-unknown-linux-gnueabi/lib/libadler-03530f9a78709cc6.rlib" "/Users/braydenzee/.rustup/toolchains/stable-aarch64-apple-darwin/lib/rustlib/arm-unknown-linux-gnueabi/lib/libunwind-cd5793ef2d0bbab7.rlib" "/Users/braydenzee/.rustup/toolchains/stable-aarch64-apple-darwin/lib/rustlib/arm-unknown-linux-gnueabi/lib/libcfg_if-8f091c3035e12743.rlib" "/Users/braydenzee/.rustup/toolchains/stable-aarch64-apple-darwin/lib/rustlib/arm-unknown-linux-gnueabi/lib/liblibc-244a7eee40908a43.rlib" "/Users/braydenzee/.rustup/toolchains/stable-aarch64-apple-darwin/lib/rustlib/arm-unknown-linux-gnueabi/lib/liballoc-780f7c19e4f567bd.rlib" "/Users/braydenzee/.rustup/toolchains/stable-aarch64-apple-darwin/lib/rustlib/arm-unknown-linux-gnueabi/lib/librustc_std_workspace_core-5be79fcb582be8f8.rlib" "/Users/braydenzee/.rustup/toolchains/stable-aarch64-apple-darwin/lib/rustlib/arm-unknown-linux-gnueabi/lib/libcore-7973391c065a5459.rlib" "/Users/braydenzee/.rustup/toolchains/stable-aarch64-apple-darwin/lib/rustlib/arm-unknown-linux-gnueabi/lib/libcompiler_builtins-1d96fdf42bdaa657.rlib" "-Wl,-Bdynamic" "-lstdc++" "-lgcc_s" "-lutil" "-lrt" "-lpthread" "-lm" "-ldl" "-lc" "-Wl,--eh-frame-hdr" "-Wl,-z,noexecstack" "-L" "/Users/braydenzee/.rustup/toolchains/stable-aarch64-apple-darwin/lib/rustlib/arm-unknown-linux-gnueabi/lib" "-o" "/Users/braydenzee/Desktop/robotrs/target/arm-unknown-linux-gnueabi/debug/deps/ctre-780ae51c3efcc338" "-Wl,--gc-sections" "-pie" "-Wl,-z,relro,-z,now" "-nodefaultlibs"
  = note: /Users/braydenzee/.gradle/toolchains/frc/2023/roborio/bin/../arm-nilrt-linux-gnueabi/sysroot/usr/lib/gcc/arm-nilrt-linux-gnueabi/12/../../../../../../../arm-nilrt-linux-gnueabi/bin/ld: /Users/braydenzee/Desktop/robotrs/target/arm-unknown-linux-gnueabi/debug/deps/ctre-780ae51c3efcc338.14zj3412z7hn0mq4.rcgu.o: in function `ctre::ffi::new_VictorSPX':
          /Users/braydenzee/Desktop/robotrs/ctre/src/main.rs:11: undefined reference to `cxxbridge1$new_VictorSPX'
          /Users/braydenzee/.gradle/toolchains/frc/2023/roborio/bin/../arm-nilrt-linux-gnueabi/sysroot/usr/lib/gcc/arm-nilrt-linux-gnueabi/12/../../../../../../../arm-nilrt-linux-gnueabi/bin/ld: /Users/braydenzee/Desktop/robotrs/target/arm-unknown-linux-gnueabi/debug/deps/ctre-780ae51c3efcc338.14zj3412z7hn0mq4.rcgu.o: in function `<ctre::ffi::VictorSPX as cxx::unique_ptr::UniquePtrTarget>::__raw':
          /Users/braydenzee/Desktop/robotrs/ctre/src/main.rs:11: undefined reference to `cxxbridge1$unique_ptr$ctre$phoenix$motorcontrol$can$VictorSPX$raw'
          /Users/braydenzee/.gradle/toolchains/frc/2023/roborio/bin/../arm-nilrt-linux-gnueabi/sysroot/usr/lib/gcc/arm-nilrt-linux-gnueabi/12/../../../../../../../arm-nilrt-linux-gnueabi/bin/ld: /Users/braydenzee/Desktop/robotrs/target/arm-unknown-linux-gnueabi/debug/deps/ctre-780ae51c3efcc338.14zj3412z7hn0mq4.rcgu.o: in function `<ctre::ffi::VictorSPX as cxx::unique_ptr::UniquePtrTarget>::__drop':
          /Users/braydenzee/Desktop/robotrs/ctre/src/main.rs:11: undefined reference to `cxxbridge1$unique_ptr$ctre$phoenix$motorcontrol$can$VictorSPX$drop'
          collect2: error: ld returned 1 exit status
          
  = note: some `extern` functions couldn't be found; some native libraries may need to be installed or have their path specified
  = note: use the `-l` flag to specify native libraries to link
  = note: use the `cargo:rustc-link-lib` directive to specify the native libraries to link with Cargo (see https://doc.rust-lang.org/cargo/reference/build-scripts.html#cargorustc-link-libkindname)

warning: `ctre` (bin "ctre") generated 1 warning
error: could not compile `ctre` (bin "ctre") due to previous error; 1 warning emitted

This compiled for a cortex A9 chip running linux from an Apple M1 laptop running macos. I assume there is something I'm missing but I can't figure out what.

@BlueZeeKing
Copy link
Author

I just tested the demo compiling for x86_64 linux from the same computer and that also didn't work. Does cxx simply not work when cross compiling?

@ray1422
Copy link

ray1422 commented Dec 28, 2024

same issue

undefined symbol: cxxbridge1$unique_ptr$[my class]$raw

@evbo
Copy link

evbo commented Feb 26, 2025

So how is anyone using this repo if it can't link properly? Does it only pertain to gcc, where order of linking matters? Should we be using a different c++ compiler?

Here's me trying to compile the last step of the demo with linking errors: #1448

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

3 participants