Rahix / avr-hal-template

cargo-generate template for avr-hal projects
Apache License 2.0
130 stars 28 forks source link

Error about linking `avr-gcc` #29

Closed gregorni closed 5 months ago

gregorni commented 5 months ago

I have set up an environment and cloned the template, but when I do cargo run in the project directory, I get an error about cargo not being able to link avr-gcc.

Full error message ``` Compiling first-arduino v0.1.0 (/var/home/gregorni/first-arduino) error: linking with `avr-gcc` failed: exit status: 1 | = note: LC_ALL="C" PATH="/var/home/gregorni/.rustup/toolchains/nightly-2024-03-22-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/bin:/var/home/gregorni/.opam/default/bin:/home/gregorni/.cargo/bin:/home/linuxbrew/.linuxbrew/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/var/home/gregorni/.local/bin" VSLANG="1033" "avr-gcc" "-mmcu=atmega328p" "/tmp/rustc5oWMeJ/symbols.o" "/var/home/gregorni/first-arduino/target/avr-atmega328p/debug/deps/first_arduino-65cdf4b7abba7cfb.arduino_hal-99453e04fd1e9bc0.arduino_hal.77352119ba531a0d-cgu.0.rcgu.o.rcgu.o" "-Wl,--as-needed" "-L" "/var/home/gregorni/first-arduino/target/avr-atmega328p/debug/deps" "-L" "/var/home/gregorni/first-arduino/target/debug/deps" "-L" "/var/home/gregorni/.rustup/toolchains/nightly-2024-03-22-x86_64-unknown-linux-gnu/lib/rustlib/avr-atmega328p/lib" "-Wl,-Bstatic" "/var/home/gregorni/first-arduino/target/avr-atmega328p/debug/deps/libcompiler_builtins-03a532b5526f00bb.rlib" "-Wl,-Bdynamic" "-lgcc" "-Wl,-z,noexecstack" "-L" "/var/home/gregorni/.rustup/toolchains/nightly-2024-03-22-x86_64-unknown-linux-gnu/lib/rustlib/avr-atmega328p/lib" "-o" "/var/home/gregorni/first-arduino/target/avr-atmega328p/debug/deps/first_arduino-65cdf4b7abba7cfb.elf" "-Wl,--gc-sections" "-no-pie" = note: /usr/lib/gcc/avr/13.1.0/../../../../avr/bin/ld: cannot find crtatmega328p.o: No such file or directory /usr/lib/gcc/avr/13.1.0/../../../../avr/bin/ld: cannot find -lm: No such file or directory /usr/lib/gcc/avr/13.1.0/../../../../avr/bin/ld: cannot find -lc: No such file or directory /usr/lib/gcc/avr/13.1.0/../../../../avr/bin/ld: cannot find -latmega328p: No such file or directory collect2: error: ld returned 1 exit status error: could not compile `first-arduino` (bin "first-arduino") due to 1 previous error ```

I'm wondering if it may have to do with the fact that I installed avrdude with Homebrew, and avr-gcc with dnf.

I'm running Universal Blue (which is based on Linux Fedora Silverblue) version 39, but I'm building the project in a toolbx container for normal Fedora. I'm trying to build for an Arduino UNO.

Rahix commented 5 months ago

Maybe you are missing the avr-libc? I am seeing

-lc: No such file or directory

in your error log. This indicated that the attempt to link libc failed.

gregorni commented 5 months ago

Indeed, I was missing that. Installed it, and everything works now. Thanks! :heart: