6

I am working on a Mac with Yosemite OS X and I'm trying to compile a program in C that I could then upload onto my Arduino. I am following a tutorial.

I tried going through and reinstalling avr-gcc, but I got the same output. I tried searching for the file crtatmega328p.o on my system, but it is nowhere to be found and the same goes for the directory.

$ avr-gcc -Os -DF_CPU=16000000UL -mmcu=atmega328p -c -o Program.o Program.c
$ avr-gcc -mmcu=atmega328p Program.o -o Program
/usr/local/lib/gcc/avr/5.2.0/../../../../avr/bin/ld: cannot find crtatmega328p.o: No such file or directory

/usr/local/lib/gcc/avr/5.2.0/../../../../avr/bin/ld: cannot find -latmega328p
collect2: error: ld returned 1 exit status
Palec
  • 10,298
  • 7
  • 52
  • 116
  • @Kavanai4 As far as I could find there is no way to program in pure C using the Arduino IDE – Brown Recluse Jul 31 '15 at 12:48
  • @Kavanai4 At the moment I only have the Arduino but I eventually want to move onto programming AVR micro controllers in the raw where Arduino IDE would be of no help. Before I spend the money on new hardware I want to make sure I can do it on the Arduino first, since I already own one. – Brown Recluse Jul 31 '15 at 21:09
  • Where did you get avr-gcc from? – Ignacio Vazquez-Abrams Aug 01 '15 at 16:13
  • @IgnacioVazquez-Abrams I compiled it from the source using [this tutorial](http://www.ladyada.net/learn/avr/setup-mac.html) – Brown Recluse Aug 01 '15 at 18:11
  • You did step 4 as well, correct? Which version did you install? – Ignacio Vazquez-Abrams Aug 01 '15 at 18:14
  • @IgnacioVazquez-Abrams: Yes, and I went through painstaking lengths to make sure every package was up to date, so avr-libc 1.8.1 – Brown Recluse Aug 01 '15 at 18:17
  • 2
    I understand that this is not a solution, but I'm going to suggest regressing to 4.9.x for the time being. 5.2.0 seems to be looking for object files that avr-libc doesn't provide, at least not with the filename given. – Ignacio Vazquez-Abrams Aug 01 '15 at 18:18
  • 2
    @IgnacioVazquez-Abrams: I installed avr-gcc-4.9.0 and the error went away. I was able to link the program, create a hex file, flash it and now the LED light is blinking! Please post your comment as an answer so I can give you credit for it. – Brown Recluse Aug 01 '15 at 21:05

1 Answers1

2

I was just hit by this issue on GNU/Linux last week.

Actually, the compiler works fine. The cause of the issue is a failed linking attempt against avr-libc.

avr-libc-1.8.1 is simply too old to work with GCC 5. Although 1.8.1 is the latest version of avr-libc, but it was released one year ago... The developing version of avr-libc has updated to catch up GCC 5, you could clone the subversion repository:

svn co svn://svn.savannah.nongnu.org/avr-libc/trunk

and compile it by yourself. If you are not familiar about how to compile yourself home-made toolchains from the source code, there are plenty of documentation and tutorial on the web.

比尔盖子
  • 2,009
  • 2
  • 32
  • 51