Go Down

Topic: undefined setup() and loop() even though these are defined (Read 1 time) previous topic - next topic


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 (https://github.com/jrowberg/i2cdevlib/tree/master/Arduino)
-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)


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?
[ I will NOT respond to personal messages, I WILL delete them, use the forum please ]


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!

RadarProject - Arduino Autopilot for RC http://radarproject.wordpress.com/

Go Up

Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

via Egeo 16
Torino, 10131