undefined setup() and loop() even though these are defined

Working on a project that involves i2c devices:
-8 MPU6050 gyro/accelerometers from Invensense
-SDA and SCL lines multiplexed via two separate multiplexers
-i2cDevLib for C++ classes to control the MPU6050s (i2cdevlib/Arduino at master · jrowberg/i2cdevlib · GitHub)
-Arduino 1.0.1 on a linux 3.6.5 kernel

I’ve written a class file (MpuSensor.cpp) that has an MPU6050 object and performs some operations on the data it receives (integration, kalman filtering, and quaternion math). This class isn’t complete yet, but the methods inside it have worked separately as functions in a basic ino file, and there is enough of it written that it should compile so far as I can tell.

When I try to compile the file MpuSensor.ino I get the following errors in Arduino’s main.cpp:
undefined reference to setup()
undefined reference to loop()
despite these functions being defined in my ino file.

Can anyone help? Why aren’t these functions being linked during compilation?

The code I’m using is attached.
Kalman.h - 3rd party class file for kalman filtering (works)

MpuSensor.ino (2.28 KB)

MpuSensor.h (1.78 KB)

MpuSensor.cpp (3.22 KB)

Kalman.h (3.3 KB)

One thing, for some odd reason the Arduino compilation system seems to require all of the library .h files to be included at top level in the .ino file (or at least this has seemed necessary for me). kalman.h isn't mentioned in MpuSensor.ino.

Did you post the complete set of compiler error messages?

You shouldn't name your .ino file the same as a .cpp file in the same project. The .ino file is converted into a .cpp file before compiling and so you get a conflict.

Changing the ino file name worked. It is also true that all of the header files need to be declared in the scope of that ino file. Thanks a bunch folks.

Funny, I had the same problem a few months ago. It took me about 3 or 4 hours of trying to solve the issue before I finally decided to post a question on the forum. Go figure!