0

I'm trying to link two object files from Makefile, but the linker keeps throwing errors at me. I can't seem to find this errors whe I search the web, so I hope anyone here can help.

In my Makefile, I successfully compile two .cpp-files to object files

DEVICE = atmega328p
#DEVICE = avr5

AVR-G++ = avr-gcc -Wall -Os -mmcu=$(DEVICE)


default: compile

compile:
    $(AVR-G++) -c blink.cpp -o blink.o
    $(AVR-G++) -c main.cpp -o main.o
    
link:
    $(AVR-G++) -o main.elf blink.o main.o

When I try to link, these errors show up:

[0][jole@LeitheMain ~/mnt/projects/avr]
  $ make link
avr-gcc -Wall -Os -mmcu=atmega328p -o main.elf blink.o main.o
/usr/bin/avr-ld: cannot find crtatmega328p.o: No such file or directory
/usr/bin/avr-ld: cannot find -lm: No such file or directory
/usr/bin/avr-ld: cannot find -lc: No such file or directory
/usr/bin/avr-ld: cannot find -latmega328p: No such file or directory
collect2: error: ld returned 1 exit status
make: *** [Makefile:15: link] Error 1

I've done a few hours searching the web, and reading avr-gcc documentation, but I still don't know why I get these erros. Is there anyone here who can help?

I've tried installing my avr-gcc toolchain again, I've read avr-gcc documentation, there is very little on -lm/-lc.

For the crtatmega328p.o, I've copied the file into the current working directory. This gets rid of that particular error, but the others remain.

I've also installed glibc, as suggested below here.

Best regards /Jon

1 Answer 1

0

Turns out I found the solution: I installed avr-libc and that fixed the problem.

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.