Before logging an issue, please update to the latest release of Visual Micro from the Downloads Page.

When Logging a Support Issue in the Forum, please ensure you have also:-

  • Enabled vMicro > Compiler > Show Build Properties
  • Re-Compile your program with these settings enabled
 
Save the new Output to a Text File and....
  • Click the Reply button and attach as .txt file OR
  • Click here to Email us with the file attached, and a link to your post
Support requests without the output above may be impossible to answer, so please help us to help you
 
Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic Multiple Definition Error (Read 2492 times)
DER_ANFÄNGER
Newbies
*
Offline


Posts: 4
Joined: Oct 3rd, 2015
Multiple Definition Error
Oct 3rd, 2015 at 5:57pm
Print Post  
Hey Guys,

I have a very basic Problem but can't solve it myself.

I want to use the I2CdevLib more accurate the file "MPU6050_6Axis_MotionApps20.h". so i have to include it to the .INO file,so the compiler "Knows" the file. but then i want also use the header in "Gyro.h". Now my Problem: 

If i include "MPU6050_6Axis_MotionApps20.h" in just the ino i get an not declaired Error.

If i include it just into the "Gyro.h"i get an File not found Error.

and if i include it into both i get an multiple definition Error so... what should i do ? :/
  
Back to top
 
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12191
Location: United Kingdom
Joined: Apr 10th, 2010
Re: Multiple Definition Error
Reply #1 - Oct 3rd, 2015 at 6:11pm
Print Post  
Hi,

Does it work when you try it with the current release of the arduino ide (1.6.5-r2)?

Thanks
  
Back to top
IP Logged
 
DER_ANFÄNGER
Newbies
*
Offline


Posts: 4
Joined: Oct 3rd, 2015
Re: Multiple Definition Error
Reply #2 - Oct 3rd, 2015 at 6:24pm
Print Post  
I usally use Visual Micro as IDE ... but i tried also the Arduino IDE (1.6.5 ) and it didn't worked. 1.6.5 r2 shouldn't be different because the only change was the problem that prevented opening the IDE when double clicking a .ino file... :/
  
Back to top
 
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12191
Location: United Kingdom
Joined: Apr 10th, 2010
Re: Multiple Definition Error
Reply #3 - Oct 3rd, 2015 at 6:40pm
Print Post  
Yes 1.6.5 is fine, most versions are okay but sometimes it saves time to test a common version.

I thought that might be the case that it failed in the arduino ide. That means it's a design problem with the code in some way.

You are right that you have to include the lib files in the master .ino otherwise the library sources are not detected during compile. This is an old rule for arduino but it might be about to change with their next ide version build process.

The main problem is that it doesn't sound like the I2CDevLib has an I2CDevLib.h. This would allow both visual micro and arduino to more clearly know the library that is required. It's the published way for a library to work.

The following rule will help:-

Normally a .h file will have an #ifndef LIBNAME condition around the code. If that's missing you will get this error when the .h is included in more than one code file.

To see the syntax use visual micro to create a "new cpp and header file"
  
Back to top
IP Logged
 
DER_ANFÄNGER
Newbies
*
Offline


Posts: 4
Joined: Oct 3rd, 2015
Re: Multiple Definition Error
Reply #4 - Oct 3rd, 2015 at 6:58pm
Print Post  
the headers from the lib have a #ifndef condition and mine too .. .:/
« Last Edit: Oct 3rd, 2015 at 6:59pm by DER_ANFÄNGER »  
Back to top
 
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12191
Location: United Kingdom
Joined: Apr 10th, 2010
Re: Multiple Definition Error
Reply #5 - Oct 3rd, 2015 at 7:06pm
Print Post  
I'm not that strong with arduino code. Why not ask on http://arduino.cc/forum. Because it also fails in the arduino ide it is a valid question for arduino.cc.
  
Back to top
IP Logged
 
DER_ANFÄNGER
Newbies
*
Offline


Posts: 4
Joined: Oct 3rd, 2015
Re: Multiple Definition Error
Reply #6 - Oct 3rd, 2015 at 7:06pm
Print Post  
Okay thank you Smiley
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint