Compilation Error: Undefined reference to main

c:/users/mdmee/appdata/local/arduino15/packages/arduino/tools/avr-gcc/7.3.0-atmel3.6.1-arduino7/bin/../lib/gcc/avr/7.3.0/../../../../avr/lib/avr5/crtatmega328p.o:(.init9+0x0): undefined reference to `main'
collect2.exe: error: ld returned 1 exit status

exit status 1

Compilation error: exit status 1

This is my code, literally the default blink example:

#include <Arduino_BuiltIn.h>

// the setup function runs once when you press reset or power the board
void setup() {
  // initialize digital pin LED_BUILTIN as an output.
  pinMode(LED_BUILTIN, OUTPUT);
}

// the loop function runs over and over again forever
void loop() {
  digitalWrite(LED_BUILTIN, HIGH);  // turn the LED on (HIGH is the voltage level)
  delay(1000);                      // wait for a second
  digitalWrite(LED_BUILTIN, LOW);   // turn the LED off by making the voltage LOW
  delay(1000);                      // wait for a second
}

Welcome to the forum

Which Arduino board are you using and which board have you got selected in the IDE ?

Hi @meeran

welcome to the arduino-Forum.
Well done to post the error-message and the code as a code-section.

You should provide much more detailed information about the compile-process.
Read this 3 minutes tutorial to learn how to adjust the Arduino-IDE to automatically create alls the detail-information

Using Arduino UNO and thats the one selected in the IDE

That is not the default Blink example

Comment out that first #include

If I select Arduino Uno in my IDE and compile your code as posted in post #1
it does compile.

So there must be something else wrong.

You can now waste hours, days and weeks by posting too short new postings or take a single time 5 minutes to read and then follow this tutorial.

This will

AUTOMATICALLY

create all the details that you do not know yet to analyse to find the error

Your compile error is in the AVR boards code. Either your install went bad, or a HDD soft fail. In either case just do a re-install of the IDE. If this persists, you need to delete the entire Arduin15 folder and any other hidden Arduino folders (at least one)

Already tried

alright ill do this

These are all the details


FQBN: arduino:avr:uno
Using board 'uno' from platform in folder: C:\Users\mdmee\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.6
Using core 'arduino' from platform in folder: C:\Users\mdmee\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.6

Detecting libraries used...
C:\Users\mdmee\AppData\Local\Arduino15\packages\arduino\tools\avr-gcc\7.3.0-atmel3.6.1-arduino7/bin/avr-g++ -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -flto -w -x c++ -E -CC -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10607 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR -IC:\Users\mdmee\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.6\cores\arduino -IC:\Users\mdmee\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.6\variants\standard C:\Users\mdmee\AppData\Local\arduino\sketches\72692CF9A2E9E385C9B7228DC9D46C74\sketch\Blink.ino.cpp -o nul
Generating function prototypes...
C:\Users\mdmee\AppData\Local\Arduino15\packages\arduino\tools\avr-gcc\7.3.0-atmel3.6.1-arduino7/bin/avr-g++ -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -flto -w -x c++ -E -CC -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10607 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR -IC:\Users\mdmee\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.6\cores\arduino -IC:\Users\mdmee\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.6\variants\standard C:\Users\mdmee\AppData\Local\arduino\sketches\72692CF9A2E9E385C9B7228DC9D46C74\sketch\Blink.ino.cpp -o C:\Users\mdmee\AppData\Local\Temp\1600574688\sketch_merged.cpp
C:\Users\mdmee\AppData\Local\Arduino15\packages\builtin\tools\ctags\5.8-arduino11/ctags -u --language-force=c++ -f - --c++-kinds=svpf --fields=KSTtzns --line-directives C:\Users\mdmee\AppData\Local\Temp\1600574688\sketch_merged.cpp
Compiling sketch...
"C:\\Users\\mdmee\\AppData\\Local\\Arduino15\\packages\\arduino\\tools\\avr-gcc\\7.3.0-atmel3.6.1-arduino7/bin/avr-g++" -c -g -Os -Wall -Wextra -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -MMD -flto -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10607 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR "-IC:\\Users\\mdmee\\AppData\\Local\\Arduino15\\packages\\arduino\\hardware\\avr\\1.8.6\\cores\\arduino" "-IC:\\Users\\mdmee\\AppData\\Local\\Arduino15\\packages\\arduino\\hardware\\avr\\1.8.6\\variants\\standard" "C:\\Users\\mdmee\\AppData\\Local\\arduino\\sketches\\72692CF9A2E9E385C9B7228DC9D46C74\\sketch\\Blink.ino.cpp" -o "C:\\Users\\mdmee\\AppData\\Local\\arduino\\sketches\\72692CF9A2E9E385C9B7228DC9D46C74\\sketch\\Blink.ino.cpp.o"
Compiling libraries...
Compiling core...
Using precompiled core: C:\Users\mdmee\AppData\Local\arduino\cores\arduino_avr_uno_566c47d9f63672ddb7f5ae3fcfffff35\core.a
Linking everything together...
"C:\\Users\\mdmee\\AppData\\Local\\Arduino15\\packages\\arduino\\tools\\avr-gcc\\7.3.0-atmel3.6.1-arduino7/bin/avr-gcc" -Wall -Wextra -Os -g -flto -fuse-linker-plugin -Wl,--gc-sections -mmcu=atmega328p -o "C:\\Users\\mdmee\\AppData\\Local\\arduino\\sketches\\72692CF9A2E9E385C9B7228DC9D46C74/Blink.ino.elf" "C:\\Users\\mdmee\\AppData\\Local\\arduino\\sketches\\72692CF9A2E9E385C9B7228DC9D46C74\\sketch\\Blink.ino.cpp.o" "C:\\Users\\mdmee\\AppData\\Local\\arduino\\sketches\\72692CF9A2E9E385C9B7228DC9D46C74/..\\..\\cores\\arduino_avr_uno_566c47d9f63672ddb7f5ae3fcfffff35\\core.a" "-LC:\\Users\\mdmee\\AppData\\Local\\arduino\\sketches\\72692CF9A2E9E385C9B7228DC9D46C74" -lm
c:/users/mdmee/appdata/local/arduino15/packages/arduino/tools/avr-gcc/7.3.0-atmel3.6.1-arduino7/bin/../lib/gcc/avr/7.3.0/../../../../avr/lib/avr5/crtatmega328p.o:(.init9+0x0): undefined reference to `main'
collect2.exe: error: ld returned 1 exit status

exit status 1

Compilation error: exit status 1

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.