Error compiling with no known errors

I have been having the same compiling error while working with my Arduino Uno. I have checked the code 6 times and cannot find anything wrong with it but whenever I attempt to compile it I receive this error:

core.a(main.cpp.o): In function main': C:\Program Files (x86)\Arduino\hardware\arduino\cores\arduino/main.cpp:14: undefined reference to loop'

And this error message comes up on anything, even a code as simple as:

#include <LiquidCrystal.h>
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);

I need help as I do not fully understand what it is saying. Thank you in advance!

Post your code.
Use code tags.

#include <LiquidCrystal.h>
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);

Of course that code wouldn't compile, where is your:

void setup(){

}
void loop(){

}

As expected by the IDE.

As the example sketch, BareMinimum, shown below, you must have a setup() and loop() function in your sketch, even if you don't put anything in them as shown here:

void setup() {
  // put your setup code here, to run once:

}

void loop() {
  // put your main code here, to run repeatedly: 
  
}

Okay I was trying to simplify the code as much as possible so that I didn't get that error message and figured it would compile even without the "void setup" part. Anyways I have the starter kit and I have copied the code exactly out of the book and I am still getting the same error code
Here is my code(I apologize, I am not sure how to use the "code tags")
#include <LiquidCrystal.h>
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);

const int sensorPin = A0;
int switchState = 0;
int prevSwitchStae = 0;
int reply;
void setup() {
lcd.begin(16,2);
pinMode (sensorPin,INPUT);
lcd.print("ask the");
lcd.setCursor(0,1);
lcd.print("Crstal Ball!");
}

and then after attempting to compile that code it gives me this error message :

core.a(main.cpp.o): In function main': C:\Program Files (x86)\Arduino\hardware\arduino\cores\arduino/main.cpp:14: undefined reference to loop'

Yup, it looks like there's no loop() there.

Yea I realize that but what part of my code is trying to reference the loop?

Yea I realize that but what part of my code is trying to reference the loop?

Your are in a

void arguing_loop_with_the_compiler(){ 

if(you want to argue = true)  keep arguing, 
else{  you put a

void loop() {
  // put your main code here, to run repeatedly: 
  
} 
and it will work
}


}

Valikir018:
Yea I realize that but what part of my code is trying to reference the loop?

It's the the part you can't see. The Aduino IDE 'wraps' your sketch around a supplied main() function to your sketch that includes an init() function to set up timer0 to kick off the hardware timer0 and defines a setup() and loop() function prototypes, so you are obligated to supply a setup() and loop() function.

Of course,

if(you want to argue = true)  keep arguing,

should be

if(you want to argue == true)  keep arguing;

Yeah your right. :wink: that is why he was continuously arguing. :stuck_out_tongue:

I'll fix that on the spot

The IDE adds:

void main(void) {
  sei();
  init();
  setup();
  for(;;){
    loop();
  }
}

Or something like that.

If you don't want loop() or setup(), just use this in your code instead:

void main(void) {
  sei();
  init();
  
  //Your code here
  
  exit();
}