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 
8
  • @Kavanai4 As far as I could find there is no way to program in pure C using the Arduino IDE Commented Jul 31, 2015 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. Commented Jul 31, 2015 at 21:09
  • Where did you get avr-gcc from? Commented Aug 1, 2015 at 16:13
  • 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. Commented Aug 1, 2015 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. Commented Aug 1, 2015 at 21:05

1 Answer 1

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.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.