# Undefined refrence to main

**URL:** <https://forum.arduino.cc/t/undefined-refrence-to-main/1185374>\
**Category:** Programming\
**Created:** [November 4, 2023, 9:55am UTC](https://forum.arduino.cc/t/undefined-refrence-to-main/1185374 "2023-11-04T09:55:58Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![spookyisreal](https://avatars.discourse-cdn.com/v4/letter/s/ba8739/32.png) [@spookyisreal](https://forum.arduino.cc/u/spookyisreal)\
**Post date:** [November 4, 2023, 9:55am UTC](https://forum.arduino.cc/t/undefined-refrence-to-main/1185374/1 "2023-11-04T09:55:58Z")

</div>

how should i be able to fix this error im about to paste below?

```arduino
c:/users/ilove/appdata/local/arduino15/packages/arduino/tools/avr-gcc/7.3.0-atmel3.6.1-arduino5/bin/../lib/gcc/avr/7.3.0/../../../../avr/lib/avrxmega3/crtatmega4809.o:../../../../crt1/gcrt1.S:310: undefined reference to `main'
collect2.exe: error: ld returned 1 exit status

exit status 1

Compilation error: exit status 1

```

for further details on my arduino:  
Board:arduino nano every  
Did i check the correct board?: yes  
port im using: com4

if you would like any details do ask me

Thanks in advance for anyone who can help!

---

<div class="post-metadata">

**Author:** ![UKHeliBob](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/ukhelibob/32/215663_2.png) [@UKHeliBob](https://forum.arduino.cc/u/UKHeliBob)\
**Post date:** [November 4, 2023, 9:57am UTC](https://forum.arduino.cc/t/undefined-refrence-to-main/1185374/2 "2023-11-04T09:57:47Z")

</div>

Welcome to the forum

Moved to Programming category

Please post the sketch that produces the error, using code tags when you do

---

<div class="post-metadata">

**Author:** ![spookyisreal](https://avatars.discourse-cdn.com/v4/letter/s/ba8739/32.png) [@spookyisreal](https://forum.arduino.cc/u/spookyisreal)\
**Post date:** [November 4, 2023, 10:25am UTC](https://forum.arduino.cc/t/undefined-refrence-to-main/1185374/3 "2023-11-04T10:25:30Z")

</div>

alright thank you!

also here is the sketch

```arduino
const int led = 13;

void setup() {
  // put your setup code here, to run once:
  pinMode(led,OUTPUT);
}

void loop() {
  // put your main code here, to run repeatedly:
  digitalWrite(led,HIGH);
  delay(500);
  digitalWrite(led,LOW);
  delay(500);
}

```

---

<div class="post-metadata">

**Author:** ![UKHeliBob](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/ukhelibob/32/215663_2.png) [@UKHeliBob](https://forum.arduino.cc/u/UKHeliBob)\
**Post date:** [November 4, 2023, 10:32am UTC](https://forum.arduino.cc/t/undefined-refrence-to-main/1185374/4 "2023-11-04T10:32:07Z")

</div>

Thank you

The problem does not appear to be with the sketch. Exactly which board have you got selected in the IDE ?

---

<div class="post-metadata">

**Author:** ![david\_2018](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/david_2018/32/1013044_2.png) [@david\_2018](https://forum.arduino.cc/u/david_2018)\
**Post date:** [November 4, 2023, 10:55am UTC](https://forum.arduino.cc/t/undefined-refrence-to-main/1185374/5 "2023-11-04T10:55:20Z")

</div>

Can you compile any other sketches for the nano every, such as the example blink sketch?  
Possibly a bad install of the IDE, or an antivirus program either deleted a file, or is interfering with the files created during the compilation.

---

<div class="post-metadata">

**Author:** ![system](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/system/32/1140315_2.png) [@system](https://forum.arduino.cc/u/system)\
**Post date:** [May 2, 2024, 10:56am UTC](https://forum.arduino.cc/t/undefined-refrence-to-main/1185374/6 "2024-05-02T10:56:09Z")

</div>

Closed on May 2, 2024, 10:56am UTC

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