Error compiling for board Arduino/Genuino Uno

Trying my firs project with DHT11 and getting the error.
I have DHT11 library included and installed.
Any suggestion, thx in advance

Linking everything together...
"C:\Program Files\arduino-1.8.5\hardware\tools\avr/bin/avr-gcc" -w -Os -g -flto -fuse-linker-plugin -Wl,--gc-sections -mmcu=atmega328p -o "C:\Users\Adam\AppData\Local\Temp\arduino_build_119428/sketch_DHT11.ino.elf" "C:\Users\Adam\AppData\Local\Temp\arduino_build_119428\sketch\sketch_DHT11.ino.cpp.o" "C:\Users\Adam\AppData\Local\Temp\arduino_build_119428\libraries\DHT\dht.cpp.o" "C:\Users\Adam\AppData\Local\Temp\arduino_build_119428/..\arduino_cache_662019\core\core_arduino_avr_uno_3eb44f8f44952eabacf4099641ad3503.a" "-LC:\Users\Adam\AppData\Local\Temp\arduino_build_119428" -lm
c:/program files/arduino-1.8.5/hardware/tools/avr/bin/../lib/gcc/avr/4.9.2/../../../../avr/lib/avr5/crtatmega328p.o:(.init9+0x0): undefined reference to `main'

collect2.exe: error: ld returned 1 exit status

Using library DHT in folder: D:\Documents\Arduino\libraries\DHT (legacy)
exit status 1
Error compiling for board Arduino/Genuino Uno.

post your full code..

Here it is:

#include <DHT11.h>

#define dht_apin A0 // Analog Pin sensor is connected to

DHT DHT;

void setup(){

Serial.begin(9600);
delay(500);//Delay to let system boot
Serial.println("DHT11 Humidity & temperature Sensor\n\n");
delay(1000);//Wait before accessing Sensor

}//end "setup()"

void loop(){
//Start of Program
float h = DHT11.readHumidity();

Serial.print("Current humidity = ");
Serial.print(h);
Serial.print("% ");
Serial.print("temperature = ");
Serial.print(t);
Serial.println("C ");

delay(5000);//Wait 5 seconds before accessing sensor again.

//Fastest should be once every two seconds.

}// end loop

DHT DHT;

You can't give the instance the exact same name as the class.

Delta_G:

DHT DHT;

You can't give the instance the exact same name as the class.

... with the exception that actually you can.

Not that I would recommend it.

Try this:

  • File > New
  • Sketch > Verify/Compile

Does it successfully compile or do you get an error?

I have the same situation. Trying to compile a new empty sketch shows there is no problem.