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

Compilation/linking issues #9

Open
alanszlosek opened this issue Aug 2, 2021 · 0 comments
Open

Compilation/linking issues #9

alanszlosek opened this issue Aug 2, 2021 · 0 comments

Comments

@alanszlosek
Copy link

I had some linking failures while compiling my own code, so I tried the sample code from Issue 6:

use std::sync::{Once, ONCE_INIT};
use mmal_sys as ffi;

fn main() {
    static INIT: Once = ONCE_INIT;
    INIT.call_once(|| unsafe {
        ffi::bcm_host_init();
        ffi::vcos_init();
        ffi::mmal_vc_init();
    });
}

I get the following output:

error: linking with `cc` failed: exit status: 1
  |
  = note: "cc" "-Wl,--eh-frame-hdr" "-Wl,-znoexecstack" "-Wl,--as-needed" "-L" "/home/pi/.rustup/toolchains/stable-armv7-unknown-linux-gnueabihf/lib/rustlib/armv7-unknown-linux-gnueabihf/lib" "/home/pi/rust-security/testing/target/debug/deps/testing-b0d24086c1dc3d34.testing.60157xxq-cgu.0.rcgu.o" "/home/pi/rust-security/testing/target/debug/deps/testing-b0d24086c1dc3d34.testing.60157xxq-cgu.1.rcgu.o" "/home/pi/rust-security/testing/target/debug/deps/testing-b0d24086c1dc3d34.testing.60157xxq-cgu.10.rcgu.o" "/home/pi/rust-security/testing/target/debug/deps/testing-b0d24086c1dc3d34.testing.60157xxq-cgu.11.rcgu.o" "/home/pi/rust-security/testing/target/debug/deps/testing-b0d24086c1dc3d34.testing.60157xxq-cgu.12.rcgu.o" "/home/pi/rust-security/testing/target/debug/deps/testing-b0d24086c1dc3d34.testing.60157xxq-cgu.2.rcgu.o" "/home/pi/rust-security/testing/target/debug/deps/testing-b0d24086c1dc3d34.testing.60157xxq-cgu.3.rcgu.o" "/home/pi/rust-security/testing/target/debug/deps/testing-b0d24086c1dc3d34.testing.60157xxq-cgu.4.rcgu.o" "/home/pi/rust-security/testing/target/debug/deps/testing-b0d24086c1dc3d34.testing.60157xxq-cgu.5.rcgu.o" "/home/pi/rust-security/testing/target/debug/deps/testing-b0d24086c1dc3d34.testing.60157xxq-cgu.6.rcgu.o" "/home/pi/rust-security/testing/target/debug/deps/testing-b0d24086c1dc3d34.testing.60157xxq-cgu.7.rcgu.o" "/home/pi/rust-security/testing/target/debug/deps/testing-b0d24086c1dc3d34.testing.60157xxq-cgu.8.rcgu.o" "/home/pi/rust-security/testing/target/debug/deps/testing-b0d24086c1dc3d34.testing.60157xxq-cgu.9.rcgu.o" "-o" "/home/pi/rust-security/testing/target/debug/deps/testing-b0d24086c1dc3d34" "/home/pi/rust-security/testing/target/debug/deps/testing-b0d24086c1dc3d34.20iabvxmbiywabro.rcgu.o" "-Wl,--gc-sections" "-pie" "-Wl,-zrelro" "-Wl,-znow" "-nodefaultlibs" "-L" "/home/pi/rust-security/testing/target/debug/deps" "-L" "/opt/vc/lib" "-L" "/home/pi/.rustup/toolchains/stable-armv7-unknown-linux-gnueabihf/lib/rustlib/armv7-unknown-linux-gnueabihf/lib" "-Wl,-Bstatic" "/home/pi/rust-security/testing/target/debug/deps/libmmal_sys-625e8ef038b80f67.rlib" "-Wl,--start-group" "/home/pi/.rustup/toolchains/stable-armv7-unknown-linux-gnueabihf/lib/rustlib/armv7-unknown-linux-gnueabihf/lib/libstd-2ecff75c0f1dd056.rlib" "/home/pi/.rustup/toolchains/stable-armv7-unknown-linux-gnueabihf/lib/rustlib/armv7-unknown-linux-gnueabihf/lib/libpanic_unwind-4407d6e80eb2ab95.rlib" "/home/pi/.rustup/toolchains/stable-armv7-unknown-linux-gnueabihf/lib/rustlib/armv7-unknown-linux-gnueabihf/lib/libminiz_oxide-638c777da661a25b.rlib" "/home/pi/.rustup/toolchains/stable-armv7-unknown-linux-gnueabihf/lib/rustlib/armv7-unknown-linux-gnueabihf/lib/libadler-0c4178ac37ad5512.rlib" "/home/pi/.rustup/toolchains/stable-armv7-unknown-linux-gnueabihf/lib/rustlib/armv7-unknown-linux-gnueabihf/lib/libobject-efb25e1f32cb3559.rlib" "/home/pi/.rustup/toolchains/stable-armv7-unknown-linux-gnueabihf/lib/rustlib/armv7-unknown-linux-gnueabihf/lib/libaddr2line-379eeb521c099c36.rlib" "/home/pi/.rustup/toolchains/stable-armv7-unknown-linux-gnueabihf/lib/rustlib/armv7-unknown-linux-gnueabihf/lib/libgimli-00419cc0cb9d5147.rlib" "/home/pi/.rustup/toolchains/stable-armv7-unknown-linux-gnueabihf/lib/rustlib/armv7-unknown-linux-gnueabihf/lib/libstd_detect-6c859df9e5c06e7c.rlib" "/home/pi/.rustup/toolchains/stable-armv7-unknown-linux-gnueabihf/lib/rustlib/armv7-unknown-linux-gnueabihf/lib/librustc_demangle-3283d3f03bb5049a.rlib" "/home/pi/.rustup/toolchains/stable-armv7-unknown-linux-gnueabihf/lib/rustlib/armv7-unknown-linux-gnueabihf/lib/libhashbrown-bd561d57a27dc1b9.rlib" "/home/pi/.rustup/toolchains/stable-armv7-unknown-linux-gnueabihf/lib/rustlib/armv7-unknown-linux-gnueabihf/lib/librustc_std_workspace_alloc-6c69cfcba7996290.rlib" "/home/pi/.rustup/toolchains/stable-armv7-unknown-linux-gnueabihf/lib/rustlib/armv7-unknown-linux-gnueabihf/lib/libunwind-ddfb123d87237579.rlib" "/home/pi/.rustup/toolchains/stable-armv7-unknown-linux-gnueabihf/lib/rustlib/armv7-unknown-linux-gnueabihf/lib/libcfg_if-9ef6a0bc94fb85ae.rlib" "/home/pi/.rustup/toolchains/stable-armv7-unknown-linux-gnueabihf/lib/rustlib/armv7-unknown-linux-gnueabihf/lib/liblibc-c506a67823d04a67.rlib" "/home/pi/.rustup/toolchains/stable-armv7-unknown-linux-gnueabihf/lib/rustlib/armv7-unknown-linux-gnueabihf/lib/liballoc-80f7d54b5818ea70.rlib" "/home/pi/.rustup/toolchains/stable-armv7-unknown-linux-gnueabihf/lib/rustlib/armv7-unknown-linux-gnueabihf/lib/librustc_std_workspace_core-5ab42311f69374fd.rlib" "/home/pi/.rustup/toolchains/stable-armv7-unknown-linux-gnueabihf/lib/rustlib/armv7-unknown-linux-gnueabihf/lib/libcore-7930b3e0f1a2487a.rlib" "-Wl,--end-group" "/home/pi/.rustup/toolchains/stable-armv7-unknown-linux-gnueabihf/lib/rustlib/armv7-unknown-linux-gnueabihf/lib/libcompiler_builtins-6003d0ba0f66a76e.rlib" "-Wl,-Bdynamic" "-lmmal_util" "-lmmal_core" "-lmmal_vc_client" "-lvcos" "-lbcm_host" "-lvchiq_arm" "-lvcsm" "-lgcc_s" "-lutil" "-lrt" "-lpthread" "-lm" "-ldl" "-lc"
  = note: /usr/bin/ld: /opt/vc/lib/libmmal_vc_client.so: undefined reference to `mmal_port_buffer_header_callback'
          /usr/bin/ld: /opt/vc/lib/libmmal_vc_client.so: undefined reference to `mmal_ports_free'
          /usr/bin/ld: /opt/vc/lib/libmmal_vc_client.so: undefined reference to `mmal_component_action_trigger'
          /usr/bin/ld: /opt/vc/lib/libmmal_vc_client.so: undefined reference to `mmal_ports_alloc'
          /usr/bin/ld: /opt/vc/lib/libmmal_vc_client.so: undefined reference to `mmal_buffer_header_release'
          /usr/bin/ld: /opt/vc/lib/libmmal_vc_client.so: undefined reference to `mmal_event_error_send'
          /usr/bin/ld: /opt/vc/lib/libmmal_vc_client.so: undefined reference to `mmal_queue_get'
          /usr/bin/ld: /opt/vc/lib/libmmal_vc_client.so: undefined reference to `mmal_buffer_header_replicate'
          /usr/bin/ld: /opt/vc/lib/libmmal_vc_client.so: undefined reference to `mmal_event_format_changed_get'
          /usr/bin/ld: /opt/vc/lib/libmmal_vc_client.so: undefined reference to `mmal_component_action_register'
          /usr/bin/ld: /opt/vc/lib/libmmal_vc_client.so: undefined reference to `mmal_format_extradata_alloc'
          /usr/bin/ld: /opt/vc/lib/libmmal_vc_client.so: undefined reference to `mmal_queue_put'
          /usr/bin/ld: /opt/vc/lib/libmmal_vc_client.so: undefined reference to `mmal_component_supplier_register'
          /usr/bin/ld: /opt/vc/lib/libmmal_vc_client.so: undefined reference to `mmal_port_alloc'
          /usr/bin/ld: /opt/vc/lib/libmmal_vc_client.so: undefined reference to `mmal_log_category'
          /usr/bin/ld: /opt/vc/lib/libmmal_vc_client.so: undefined reference to `mmal_port_event_get'
          /usr/bin/ld: /opt/vc/lib/libmmal_vc_client.so: undefined reference to `mmal_queue_create'
          /usr/bin/ld: /opt/vc/lib/libmmal_vc_client.so: undefined reference to `mmal_buffer_header_driver_data'
          /usr/bin/ld: /opt/vc/lib/libmmal_vc_client.so: undefined reference to `mmal_queue_destroy'
          /usr/bin/ld: /opt/vc/lib/libmmal_vc_client.so: undefined reference to `mmal_queue_length'
          /usr/bin/ld: /opt/vc/lib/libmmal_vc_client.so: undefined reference to `mmal_port_free'
          /usr/bin/ld: /opt/vc/lib/libmmal_vc_client.so: undefined reference to `mmal_4cc_to_string'
          /usr/bin/ld: /opt/vc/lib/libmmal_vc_client.so: undefined reference to `mmal_format_copy'
          /usr/bin/ld: /opt/vc/lib/libmmal_vc_client.so: undefined reference to `mmal_status_to_string'
          /usr/bin/ld: /opt/vc/lib/libmmal_vc_client.so: undefined reference to `mmal_port_event_send'
          collect2: error: ld returned 1 exit status
          

error: aborting due to previous error; 2 warnings emitted

In the meantime is there a way I can work around this by changing the link order in the dependency that Cargo pulls down, then rebuilding that dependency? I'm new to Rust so I don't know how to go about this.

Thanks for your help.

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