user27157: As many of you know (if you read my bio or simply read my previous questions), I'm trying to build a rocket. The code was going well, but once I split my objects into 2 files, a .h and .cpp file, this error message appeared.
The full code is on GitHub because it is simply too long!
Here is the error message :
Arduino: 1.8.1 (Windows 7), Board: "Arduino Pro or Pro Mini, ATmega328 (5V, 16 MHz)"

sketch\vehicle.ino.cpp.o (symbol from plugin): In function `Fins':

(.text+0x0): multiple definition of `MPU6050::dmpInitialize()'

sketch\Gyroscope.cpp.o (symbol from plugin):(.text+0x0): first defined here

sketch\vehicle.ino.cpp.o (symbol from plugin): In function `Fins':

(.text+0x0): multiple definition of `MPU6050::dmpPacketAvailable()'

sketch\Gyroscope.cpp.o (symbol from plugin):(.text+0x0): first defined here

sketch\vehicle.ino.cpp.o (symbol from plugin): In function `Fins':

(.text+0x0): multiple definition of `MPU6050::dmpGetAccel(long*, unsigned char const*)'

sketch\Gyroscope.cpp.o (symbol from plugin):(.text+0x0): first defined here

sketch\vehicle.ino.cpp.o (symbol from plugin): In function `Fins':

(.text+0x0): multiple definition of `MPU6050::dmpGetAccel(int*, unsigned char const*)'

sketch\Gyroscope.cpp.o (symbol from plugin):(.text+0x0): first defined here

sketch\vehicle.ino.cpp.o (symbol from plugin): In function `Fins':

(.text+0x0): multiple definition of `MPU6050::dmpGetAccel(VectorInt16*, unsigned char const*)'

sketch\Gyroscope.cpp.o (symbol from plugin):(.text+0x0): first defined here

sketch\vehicle.ino.cpp.o (symbol from plugin): In function `Fins':

(.text+0x0): multiple definition of `MPU6050::dmpGetQuaternion(long*, unsigned char const*)'

sketch\Gyroscope.cpp.o (symbol from plugin):(.text+0x0): first defined here

sketch\vehicle.ino.cpp.o (symbol from plugin): In function `Fins':

(.text+0x0): multiple definition of `MPU6050::dmpGetQuaternion(int*, unsigned char const*)'

sketch\Gyroscope.cpp.o (symbol from plugin):(.text+0x0): first defined here

sketch\vehicle.ino.cpp.o (symbol from plugin): In function `Fins':

(.text+0x0): multiple definition of `MPU6050::dmpGetQuaternion(Quaternion*, unsigned char const*)'

sketch\Gyroscope.cpp.o (symbol from plugin):(.text+0x0): first defined here

sketch\vehicle.ino.cpp.o (symbol from plugin): In function `Fins':

(.text+0x0): multiple definition of `MPU6050::dmpGetGyro(long*, unsigned char const*)'

sketch\Gyroscope.cpp.o (symbol from plugin):(.text+0x0): first defined here

sketch\vehicle.ino.cpp.o (symbol from plugin): In function `Fins':

(.text+0x0): multiple definition of `MPU6050::dmpGetGyro(int*, unsigned char const*)'

sketch\Gyroscope.cpp.o (symbol from plugin):(.text+0x0): first defined here

sketch\vehicle.ino.cpp.o (symbol from plugin): In function `Fins':

(.text+0x0): multiple definition of `MPU6050::dmpGetGyro(VectorInt16*, unsigned char const*)'

sketch\Gyroscope.cpp.o (symbol from plugin):(.text+0x0): first defined here

sketch\vehicle.ino.cpp.o (symbol from plugin): In function `Fins':

(.text+0x0): multiple definition of `MPU6050::dmpGetLinearAccel(VectorInt16*, VectorInt16*, VectorFloat*)'

sketch\Gyroscope.cpp.o (symbol from plugin):(.text+0x0): first defined here

sketch\vehicle.ino.cpp.o (symbol from plugin): In function `Fins':

(.text+0x0): multiple definition of `MPU6050::dmpGetLinearAccelInWorld(VectorInt16*, VectorInt16*, Quaternion*)'

sketch\Gyroscope.cpp.o (symbol from plugin):(.text+0x0): first defined here

sketch\vehicle.ino.cpp.o (symbol from plugin): In function `Fins':

(.text+0x0): multiple definition of `MPU6050::dmpGetGravity(VectorFloat*, Quaternion*)'

sketch\Gyroscope.cpp.o (symbol from plugin):(.text+0x0): first defined here

sketch\vehicle.ino.cpp.o (symbol from plugin): In function `Fins':

(.text+0x0): multiple definition of `MPU6050::dmpGetEuler(float*, Quaternion*)'

sketch\Gyroscope.cpp.o (symbol from plugin):(.text+0x0): first defined here

sketch\vehicle.ino.cpp.o (symbol from plugin): In function `Fins':

(.text+0x0): multiple definition of `MPU6050::dmpGetYawPitchRoll(float*, Quaternion*, VectorFloat*)'

sketch\Gyroscope.cpp.o (symbol from plugin):(.text+0x0): first defined here

sketch\vehicle.ino.cpp.o (symbol from plugin): In function `Fins':

(.text+0x0): multiple definition of `MPU6050::dmpProcessFIFOPacket(unsigned char const*)'

sketch\Gyroscope.cpp.o (symbol from plugin):(.text+0x0): first defined here

sketch\vehicle.ino.cpp.o (symbol from plugin): In function `Fins':

(.text+0x0): multiple definition of `MPU6050::dmpReadAndProcessFIFOPacket(unsigned char, unsigned char*)'

sketch\Gyroscope.cpp.o (symbol from plugin):(.text+0x0): first defined here

sketch\vehicle.ino.cpp.o (symbol from plugin): In function `Fins':

(.text+0x0): multiple definition of `MPU6050::dmpGetFIFOPacketSize()'

sketch\Gyroscope.cpp.o (symbol from plugin):(.text+0x0): first defined here

exit status 1
Error compiling for board Arduino Pro or Pro Mini.

This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.


user26916: The problem is the way the author of the MPU6050 library wrote MPU6050_6Axis_MotionApps20.h is not compatible with the way you're using the library. Multiple proposals for fixing the issue have been submitted but they are all outdated to some extent:
https://github.com/jrowberg/i2cdevlib/pull/174
download at https://github.com/martinjos/i2cdevlib/archive/master.zip
https://github.com/jrowberg/i2cdevlib/pull/162
download at https://github.com/cgel/i2cdevlib/archive/master.zip
https://github.com/jrowberg/i2cdevlib/pull/268
download at https://github.com/onliner10/i2cdevlib/archive/master.zip

user69581: This is 3 years way too late, but here's what I did

In my own mpu_sensor.h file, I only included

#ifndef MPU_SENSOR_H
#define MPU_SENSOR_H

#include "MPU6050.h"
#include "helper_3dmath.h"
....
#endif

Note that I don't include MPU6050_6Axis_MotionApps20, since most datatypes are declared in MPU6050 and helper_3dmath

In my mpu_sensor.cpp file, here's my includes:

#include "MPU6050_6Axis_MotionApps20.h"
#include "mpu_sensor.h"

Please note that MPU6050_6Axis_MotionApps20.h must be before the line that includes mpu_sensor.h.
It works now.
I agree that the library itself should be updated, but it seems like the author is not updating for the past few years.

27157: <p>As many of you know (if you read my bio or simply read my previous questions), I'm trying to build a rocket. The code was going well, but once I split my objects into 2 files, a <code>.h</code> and <code>.cpp</code> file, this error message appeared.</p>

<p><a href="https://github.com/datha13/Rocket" rel="nofollow noreferrer">The full code is on GitHub because it is simply too long!</a></p>

<p>Here is the error message :</p>

<pre><code>Arduino: 1.8.1 (Windows 7), Board: "Arduino Pro or Pro Mini, ATmega328 (5V, 16 MHz)"

sketch\vehicle.ino.cpp.o (symbol from plugin): In function `Fins':

(.text+0x0): multiple definition of `MPU6050::dmpInitialize()'

sketch\Gyroscope.cpp.o (symbol from plugin):(.text+0x0): first defined here

sketch\vehicle.ino.cpp.o (symbol from plugin): In function `Fins':

(.text+0x0): multiple definition of `MPU6050::dmpPacketAvailable()'

sketch\Gyroscope.cpp.o (symbol from plugin):(.text+0x0): first defined here

sketch\vehicle.ino.cpp.o (symbol from plugin): In function `Fins':

(.text+0x0): multiple definition of `MPU6050::dmpGetAccel(long*, unsigned char const*)'

sketch\Gyroscope.cpp.o (symbol from plugin):(.text+0x0): first defined here

sketch\vehicle.ino.cpp.o (symbol from plugin): In function `Fins':

(.text+0x0): multiple definition of `MPU6050::dmpGetAccel(int*, unsigned char const*)'

sketch\Gyroscope.cpp.o (symbol from plugin):(.text+0x0): first defined here

sketch\vehicle.ino.cpp.o (symbol from plugin): In function `Fins':

(.text+0x0): multiple definition of `MPU6050::dmpGetAccel(VectorInt16*, unsigned char const*)'

sketch\Gyroscope.cpp.o (symbol from plugin):(.text+0x0): first defined here

sketch\vehicle.ino.cpp.o (symbol from plugin): In function `Fins':

(.text+0x0): multiple definition of `MPU6050::dmpGetQuaternion(long*, unsigned char const*)'

sketch\Gyroscope.cpp.o (symbol from plugin):(.text+0x0): first defined here

sketch\vehicle.ino.cpp.o (symbol from plugin): In function `Fins':

(.text+0x0): multiple definition of `MPU6050::dmpGetQuaternion(int*, unsigned char const*)'

sketch\Gyroscope.cpp.o (symbol from plugin):(.text+0x0): first defined here

sketch\vehicle.ino.cpp.o (symbol from plugin): In function `Fins':

(.text+0x0): multiple definition of `MPU6050::dmpGetQuaternion(Quaternion*, unsigned char const*)'

sketch\Gyroscope.cpp.o (symbol from plugin):(.text+0x0): first defined here

sketch\vehicle.ino.cpp.o (symbol from plugin): In function `Fins':

(.text+0x0): multiple definition of `MPU6050::dmpGetGyro(long*, unsigned char const*)'

sketch\Gyroscope.cpp.o (symbol from plugin):(.text+0x0): first defined here

sketch\vehicle.ino.cpp.o (symbol from plugin): In function `Fins':

(.text+0x0): multiple definition of `MPU6050::dmpGetGyro(int*, unsigned char const*)'

sketch\Gyroscope.cpp.o (symbol from plugin):(.text+0x0): first defined here

sketch\vehicle.ino.cpp.o (symbol from plugin): In function `Fins':

(.text+0x0): multiple definition of `MPU6050::dmpGetGyro(VectorInt16*, unsigned char const*)'

sketch\Gyroscope.cpp.o (symbol from plugin):(.text+0x0): first defined here

sketch\vehicle.ino.cpp.o (symbol from plugin): In function `Fins':

(.text+0x0): multiple definition of `MPU6050::dmpGetLinearAccel(VectorInt16*, VectorInt16*, VectorFloat*)'

sketch\Gyroscope.cpp.o (symbol from plugin):(.text+0x0): first defined here

sketch\vehicle.ino.cpp.o (symbol from plugin): In function `Fins':

(.text+0x0): multiple definition of `MPU6050::dmpGetLinearAccelInWorld(VectorInt16*, VectorInt16*, Quaternion*)'

sketch\Gyroscope.cpp.o (symbol from plugin):(.text+0x0): first defined here

sketch\vehicle.ino.cpp.o (symbol from plugin): In function `Fins':

(.text+0x0): multiple definition of `MPU6050::dmpGetGravity(VectorFloat*, Quaternion*)'

sketch\Gyroscope.cpp.o (symbol from plugin):(.text+0x0): first defined here

sketch\vehicle.ino.cpp.o (symbol from plugin): In function `Fins':

(.text+0x0): multiple definition of `MPU6050::dmpGetEuler(float*, Quaternion*)'

sketch\Gyroscope.cpp.o (symbol from plugin):(.text+0x0): first defined here

sketch\vehicle.ino.cpp.o (symbol from plugin): In function `Fins':

(.text+0x0): multiple definition of `MPU6050::dmpGetYawPitchRoll(float*, Quaternion*, VectorFloat*)'

sketch\Gyroscope.cpp.o (symbol from plugin):(.text+0x0): first defined here

sketch\vehicle.ino.cpp.o (symbol from plugin): In function `Fins':

(.text+0x0): multiple definition of `MPU6050::dmpProcessFIFOPacket(unsigned char const*)'

sketch\Gyroscope.cpp.o (symbol from plugin):(.text+0x0): first defined here

sketch\vehicle.ino.cpp.o (symbol from plugin): In function `Fins':

(.text+0x0): multiple definition of `MPU6050::dmpReadAndProcessFIFOPacket(unsigned char, unsigned char*)'

sketch\Gyroscope.cpp.o (symbol from plugin):(.text+0x0): first defined here

sketch\vehicle.ino.cpp.o (symbol from plugin): In function `Fins':

(.text+0x0): multiple definition of `MPU6050::dmpGetFIFOPacketSize()'

sketch\Gyroscope.cpp.o (symbol from plugin):(.text+0x0): first defined here

exit status 1
Error compiling for board Arduino Pro or Pro Mini.

This report would have more information with
"Show verbose output during compilation"
option enabled in File -&gt; Preferences.
</code></pre>
 26916: <p>The problem is the way the author of the MPU6050 library wrote MPU6050_6Axis_MotionApps20.h is not compatible with the way you're using the library. Multiple proposals for fixing the issue have been submitted but they are all outdated to some extent:</p>

<p><a href="https://github.com/jrowberg/i2cdevlib/pull/174" rel="nofollow noreferrer">https://github.com/jrowberg/i2cdevlib/pull/174</a></p>

<p>download at <a href="https://github.com/martinjos/i2cdevlib/archive/master.zip" rel="nofollow noreferrer">https://github.com/martinjos/i2cdevlib/archive/master.zip</a></p>

<p><a href="https://github.com/jrowberg/i2cdevlib/pull/162" rel="nofollow noreferrer">https://github.com/jrowberg/i2cdevlib/pull/162</a></p>

<p>download at <a href="https://github.com/cgel/i2cdevlib/archive/master.zip" rel="nofollow noreferrer">https://github.com/cgel/i2cdevlib/archive/master.zip</a></p>

<p><a href="https://github.com/jrowberg/i2cdevlib/pull/268" rel="nofollow noreferrer">https://github.com/jrowberg/i2cdevlib/pull/268</a></p>

<p>download at <a href="https://github.com/onliner10/i2cdevlib/archive/master.zip" rel="nofollow noreferrer">https://github.com/onliner10/i2cdevlib/archive/master.zip</a></p>
 69581: <p>This is 3 years way too late, but here's what I did</p>
<ol>
<li>In my own <code>mpu_sensor.h</code> file, I only included</li>
</ol>
<pre><code>#ifndef MPU_SENSOR_H
#define MPU_SENSOR_H

#include &quot;MPU6050.h&quot;
#include &quot;helper_3dmath.h&quot;
....
#endif
</code></pre>
<p>Note that I don't include <code>MPU6050_6Axis_MotionApps20</code>, since most datatypes are declared in <code>MPU6050</code> and <code>helper_3dmath</code></p>
<ol start="2">
<li>In my <code>mpu_sensor.cpp</code> file, here's my includes:</li>
</ol>
<pre><code>#include &quot;MPU6050_6Axis_MotionApps20.h&quot;
#include &quot;mpu_sensor.h&quot;
</code></pre>
<p>Please note that <code>MPU6050_6Axis_MotionApps20.h</code> must be before the line that includes <code>mpu_sensor.h</code>.</p>
<p>It works now.
I agree that the library itself should be updated, but it seems like the author is not updating for the past few years.</p>
