Multiple defintion error, Linker error Trying to create an elf file for two sets of files in different folders.

LIDARBOT.h
-----------
#ifndef LIDARBOT_H_
#define LIDARBOT_H_

#include &lt;avr/io.h&gt;
#include "drivers/motors.h"

#endif

LIDARBOT.C
----------
#include "LIDARBOT.h"
int main(){
  pwmtimersetup();
    while (1) {
    }
}

motors.h
--------
#ifndef MOTORS_H_
#define MOTORS_H_

#include &lt;avr/io.h&gt;

void pwmtimersetup(void);

#endif

motors.c
--------
#include &lt;avr/io.h&gt;
#include "motors.h"

void pwmtimersetup(void){
  // Timer pre-scalar for ~490 Hz is 8
  TCCR0B &amp;= ~((1&lt;&lt;CS02)||(1&lt;&lt;CS00));
  TCCR0B |=  (1&lt;&lt;CS01);
  // Set Compare Output Mode to Toggle PWM
  TCCR0A &amp;= ~(1&lt;&lt;COM0A1);
  TCCR0A |=  (1&lt;&lt;COM0A0);
  // Waveform Generation Mode: WGM02 = 1, WGM01 = 1, WGM00 = 1
  TCCR0B |= (1&lt;&lt;WGM02);
  TCCR0A |= (1&lt;&lt;WGM01)||(1&lt;&lt;WGM00);
  OCR0A = 125;
  DDRD |= (1&lt;&lt;DDD4)||(1&lt;&lt;DDD2);
  PORTD |= (1&lt;&lt;PORTD4);
  PORTD &amp;= (1&lt;&lt;PORTD2);
}


I can make a consolidated object file but not an elf file to load onto my board. Output below:

avr-gcc -g -Os -Wall -Werror -Wextra  -mmcu=atmega328p -DF_CPU=1000000UL -Wa,-ahlmns=LIDARBOT.lst -o objects/LIDARBOT.o \
source/LIDARBOT.c \
source/drivers/motors.c \
-I/home/manu/C/Arduino/LIDARBOT/libraries/

avr-gcc -g -Os -Wall -Werror -Wextra -mmcu=atmega328p -DF_CPU=1000000UL -o elf/LIDARBOT.elf objects/LIDARBOT.o
objects/LIDARBOT.o: In function `__vector_22':
(.text+0x7c): multiple definition of `__bad_interrupt'
/usr/lib/gcc/avr/5.4.0/../../../avr/lib/avr5/crtatmega328p.o:(.text+0x0): first defined here
objects/LIDARBOT.o: In function `__vectors':
(.text+0x0): multiple definition of `__vectors'
/usr/lib/gcc/avr/5.4.0/../../../avr/lib/avr5/crtatmega328p.o:(.vectors+0x0): first defined here
collect2: error: ld returned 1 exit status
make: *** [Makefile:191: elf] Error 1


I am kind of lost. What could be my mistake here? If I see an error like this how do i start to debug?
You forgot the -c flag to your first command. That means you have first compiled your program into a full elf file. Then you try to link that elf file with the standard startup libraries again (it already contains them) into another new elf file.

And so you get duplicate entries in it.

Add -c to your first command, which means "compile only, don't link" to create object files not an elf file.