Undefined Setup/Loop Issue

I'm having a bit of trouble with a compiling error and I'm a bit lost as to what I should do. To start, I know close to nothing about programming/programming languages. However, I am trying to make an Arduino weather station as a gift for my husband (project GitHub is located here.) and I'm stuck at an undefined setup / undefined loop error. Here is the code that I downloaded from the GitHub:

For the record, I have searched on the issue and I do understand that the code needs to have a loop/setup void included since the .cpp file calls for those. However, no matter where I try to place a void, the errors continue. For example, I've tried putting it at the beginning, like this:

#ifndef __BME280_H__
#define __BME280_H__

#if (ARDUINO >= 100)
 #include "Arduino.h"
#else
 #include "WProgram.h"
#endif

#include <Adafruit_Sensor.h>
#include <Wire.h>

void loop(){
void setup();
}

I've tried placing it elsewhere in the code, as well, and still I get the errors. I'm certain I must be missing something incredibly simple, but my lack of knowledge with this just has me completely lost as to what to do. Any help would be greatly appreciated!

P.S. - I didn't post all of the code because it apparently exceeds the 9000 character limit. Sorry!

You need to close loop() before you start setup().

void loop()
{
}

void setup()
{
}

Do yourself a real favor, and get consistent with where you put curly braces.

When I run the Arduino development app and click new to create a new sketch, this is what I get:

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

}

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

}

It shows a distinct setup function and loop function. You have one nested inside the other.

Oh, you used code tags on your first post! YAY!!! karma++

void loop(){
void setup();
}

Needs to be

void setup()
{
}

void loop()
{
}

This page may be of interest.

vinceherman:
It shows a distinct setup function and loop function. You have one nested inside the other.

Oh, you used code tags on your first post! YAY!!! karma++

Oh, this is very helpful to know. Thank you! Since I have been loading up code rather than writing my own, I was unaware of that!

I have cleaned it up so that it's now like this:

#ifndef __BME280_H__
#define __BME280_H__

#if (ARDUINO >= 100)
 #include "Arduino.h"
#else
 #include "WProgram.h"
#endif

#include <Adafruit_Sensor.h>
#include <Wire.h>

void setup()
{
}

void loop()
{
}

But I'm still getting the errors. So that leads me to believe that I'm not placing it in the correct spot or that there's something else going on. I'll have to poke around at it a bit more to see what I can figure out.

#ifndef __BME280_H__
#define __BME280_H__

These are include guards for a header file. They have no place in a sketch.

#if (ARDUINO >= 100)
 #include "Arduino.h"
#else
 #include "WProgram.h"
#endif

If you are writing new code, you do not need to support old versions of the IDE.

If you provide a link to where exactly this code came from we might have a better chance of working out what's going on.

And a complete listing of the errors you get would also help.

Steve

slipstick:
If you provide a link to where exactly this code came from we might have a better chance of working out what's going on.

And a complete listing of the errors you get would also help.

Steve

I actually did link to it in my original post

Cantaloupe:
(project GitHub is located here.)

Though, to be more specific, it's from the weather-station.ino file. Maybe that's not the appropriate file for use in Sketch? As for the complete list of errors, that's really it. Just the two errors. I don't know that it helps, but here's the output anyway.

core.a(main.cpp.o): In function `main':
/usr/share/arduino/hardware/arduino/cores/arduino/main.cpp:11: undefined reference to `setup'
/usr/share/arduino/hardware/arduino/cores/arduino/main.cpp:14: undefined reference to `loop'
collect2: error: ld returned 1 exit status

Edit: Foolish me, I didn't link directly to the .ino file like I had intended. Fixed it, though!

Please do this:

  • File > New
  • Sketch > Verify/Compile

Does an error occur?

pert:
Please do this:

  • File > New
  • Sketch > Verify/Compile

Does an error occur?

It does. Hm...is something not pointing to the correct place, then?

Cantaloupe:
It does. Hm...is something not pointing to the correct place, then?

Post the code YOU get when you use File + New.

Use File + Preferences, and click the Verbose mode for compilation checkbox. Post the complete output.

Try attaching the code that you're trying to compile to a post as described in "How to use this forum - please read".

The weather.ino that I just picked up from your link doesn't contain anything like the code you posted in your first post. I haven't got all the libraries needed to compile it and I can't be bothered to try to find them all but it definitely does contain both setup() and loop().

Steve

Ok, so I've attached both the weather-station.ino file that I've been having the problem with and the error output when creating a new Sketch (File > New) and then running Verify/Compile. I hope this helps!

weather-station.ino (15.5 KB)

error_output.txt (13.6 KB)

You're using an extremely outdated version of the Arduino IDE, probably because you installed it via a Linux package manager. Please download and install the official version of the Arduino IDE from:

pert:
You're using an extremely outdated version of the Arduino IDE, probably because you installed it via a Linux package manager. Please download and install the official version of the Arduino IDE from:
http://www.arduino.cc/en/Main/Software

And this solved it, thank you! I had used apt-get to quickly install Arduino IDE. The newer version completely eliminates the error for me. Now I can focus on all of the other errors, hah. Thank you all so much for the help!

Glad to hear! That gets a lot of people. It's very unfortunate that the Linux packages are so out of date. To make matters worse they are modified from the original IDE so there may be bugs that we aren't familiar with.

I realized that the old IDE versions gave a blank sketch on File > New so in fact my suggested minimal test was probably a bit too minimal. In the recent versions of the Arduino IDE File > New gives the bare minimum sketch with just an empty setup and loop definition so it makes a good sanity check.

If you get stuck with any of these new errors I'm sure we can help you with. Just a hint, there are URLs where you can download the library dependencies listed in this file:

Unfortunately I didn't find that file until after I had searched all over and tried multiple e-paper libraries. The three Adafruit libraries can actually be installed via Library Manager (Sketch > Include Library > Manage Libraries) if you want an even easier installation but the e-paper library will need to be manually installed.