LoginSignup
0
0

More than 3 years have passed since last update.

[小ネタ] MacOSでQMKが"cannot find crtatmega32u4.o"でビルドできないときの対応

Posted at

発端

キーボードを自作すると思い立って、パーツを買う前にqmkをMacに入れていた。
入れ方は
brew install qmk

さてそれから半年以上たって今回ようやくパーツを買って組み立てた。
さてキーマップをいじろう…と思って
make claw44:default:avrdude
してみたところ


QMK Firmware 0.9.50
Making claw44/rev1 with keymap default

avr-gcc (Homebrew AVR GCC 8.4.0) 8.4.0
Copyright (C) 2018 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

Linking: .build/claw44_rev1_default.elf                                                             [ERRORS]
 | 
 | /usr/local/opt/avr-binutils/bin/avr-ld: cannot find crtatmega32u4.o: No such file or directory
 | /usr/local/opt/avr-binutils/bin/avr-ld: cannot find -latmega32u4
 | collect2: error: ld returned 1 exit status
 | 
make[1]: *** [.build/claw44_rev1_default.elf] Error 1
make: *** [claw44:default] Error 1
Make finished with errors

でビルドに失敗する…

対策

https://github.com/osx-cross/homebrew-avr/issues/182
にあった。要はavr-gccを完全に入れ直せばよい。

  1. brew search osx-cross/avrでどのavr関連クロスコンパイルツールが入っているか確認する。私の環境ではavr-binutilsavr-gccavr-gcc@7avr-gcc@8が入っていた。
  2. brew uninstall avr-gcc@7
  3. brew uninstall avr-gcc
  4. brew uninstall avr-gcc@8とすると
Error: Refusing to uninstall /usr/local/Cellar/avr-gcc@8/8.4.0
because it is required by qmk, which is currently installed.
You can override this and force removal with:
  brew uninstall --ignore-dependencies avr-gcc@8

と警告されたので指示に従いbrew uninstall --ignore-dependencies avr-gcc@8を実行
5. brew cleanup -s -sオプションはキャッシュのクリア。
6. brew install avr-gccを実行。しばらく時間がかかる。無事にインストールできれば完了。

これでQMKのビルドは通るようになった。

考察

対策後brew search osx-cross/avrするとavr-binutilsavr-gccだけインストールされておりavr-gcc@7 avr-gcc@8は入っていなかった。
QMKを前にインストールしてから時間が半年以上経過し途中でOSをCatalinaにアップグレードしたためbrewもアップグレードされた。そこで何か失敗したのかもしれない。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0