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
Hot Topic (More than 8 Replies) multiple definition of only in visual micro (Read 16591 times)
_oesile_
Newbies
*
Offline


Posts: 7
Joined: Nov 2nd, 2014
multiple definition of only in visual micro
Nov 2nd, 2014 at 6:28pm
Print Post  
Hello, 

I am trying to compile an sketch (ino) from vs2013+visual micro but I get the following messages:

core.a(wiring.c.o)*:In function `__vector_16'
wiring.c:multiple definition of `__vector_16'
stepper.c.o:D:\Projects\Arduino\libraries\xxx\stepper.c:429: first defined here

But if I open the same sketch in arduino IDE I can compile without problems. Cry...  I don't know what happend.

Somebody can help me?

vs2013 - win 8.1
vm 1.1407.10   5
arduino 1.0.6

« Last Edit: Nov 2nd, 2014 at 6:30pm by _oesile_ »  
Back to top
 
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12189
Location: United Kingdom
Joined: Apr 10th, 2010
Re: multiple definition of only in visual micro
Reply #1 - Nov 2nd, 2014 at 7:22pm
Print Post  
Hi,

It looks like you have a library in D:\Projects\Arduino\libraries\xxx that Visual Micro is finding the stepper.c file in.

Try moving D:\Projects\Arduino\libraries\xxx somewhere else then click "tools>visual micro>reload toolchain" or re-start 2013

Thanks
  
Back to top
IP Logged
 
_oesile_
Newbies
*
Offline


Posts: 7
Joined: Nov 2nd, 2014
Re: multiple definition of only in visual micro
Reply #2 - Nov 2nd, 2014 at 8:36pm
Print Post  
Thank you, for your quick reply.

Yes, XXX it is a user library and I need it for my program. I have my sketchbook location pointing to D:\Projects\Arduino\libraries (in both arduino and visual micro). If I change the location I can not use the library any more.   In the arduino IDE everything compile prefect but I wanna use VS2013 + visual micro  Smiley

Do you have another idea?

Thanks!
« Last Edit: Nov 2nd, 2014 at 8:38pm by _oesile_ »  
Back to top
 
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12189
Location: United Kingdom
Joined: Apr 10th, 2010
Re: multiple definition of only in visual micro
Reply #3 - Nov 2nd, 2014 at 9:07pm
Print Post  
Hi,

Oh I see, it's a strange library name I thought it was an old backup of a lib Smiley

Okay well you are using 1.0.6 and Visual Micro attempts to cater for all Arduino releases including the 1.5.x beta versions that are soon to be fully released as 1.6.0 replacing 1.0.6

One area of the arduino beta program that has has significant changes in the past year is more flexibility surrounding libraries but at the same time library naming rules have become a little stricter. 

These changes should not affect your compile in this way when using the 1.0.6 system however it can under a few circumstances.

It's normally easily resolved but before I explain more let me ask you what the #includes in the sketch code are for this library and what it was called before it was called xxx?

Thanks
« Last Edit: Nov 2nd, 2014 at 9:10pm by Tim@Visual Micro »  
Back to top
IP Logged
 
_oesile_
Newbies
*
Offline


Posts: 7
Joined: Nov 2nd, 2014
Re: multiple definition of only in visual micro
Reply #4 - Nov 2nd, 2014 at 9:58pm
Print Post  
well actually the name is grbl, I wrote XXX just to be "generic" with the name, if somebody else has the same problem with another library (maybe is not good idea  Roll Eyes). 
I knew that I have to be careful with the names so the name is simple.

the #includes are:

#include <system.h>
#include <config.h>
#include <coolant_control.h>
#include <cpu_map.h>
#include <defaults.h>
#include <eeprom.h>
#include <gcode.h>
#include <limits.h>
#include <motion_control.h>
#include <nuts_bolts.h>
#include <planner.h>
#include <print.h>
#include <probe.h>
#include <protocol.h>
#include <report.h>
#include <serial.h>
#include <settings.h>
#include <spindle_control.h>
#include <stepper.h>
  
Back to top
 
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12189
Location: United Kingdom
Joined: Apr 10th, 2010
Re: multiple definition of only in visual micro
Reply #5 - Nov 2nd, 2014 at 10:50pm
Print Post  
Okay well here is some info that I hope will make it easy for you to sort out and also prevent breakage when you add other libs in the future.

First of all, the problem will be that one or more of the #includes exist in more than one library folder. It is okay for libraries to contain the same named sources but consider how the correct source is identified for the compiler...

Notice that arduino does not use folder names within the #include syntax. This is the root of the problem.

The normal rules for an Arduino library say that a library will contain a .h file of the same name.

So your "grbl" library folder would contain a file called grbl.h and be #included in the sketch. In this case Visual Micro should discover the grbl library and its sources first.

If Visual Micro can not find any includes that match library folder names then the resolution of libraries becomes a little more hit and miss, in as much as Visual Micro has to look through the installed library folders in no specific order to try to discover which files belong to which library.

So, a fix for you is probably to just to add a dummy grbl.h and grbl.cpp to the grbl library folder. This will certainly make it a more "official" arduino library and allow it to be resolved After reloading the toolchain this might well fix the issue.

Hopefully you can see that working without official lib/.h combinations and without qualified library names in #includes is prone to issues. 

Visual Micro also provides and alternative solution but it probably won't allow the code to compile in the arduino Ide just yet. That is we support qualifying the #includes with the lib folder name. For example:-

#include <grbl/system.h>
#include <grbl/config.h>

As said previously, there have been many changes by arduino to how libraries work during the past year or so and whilst your combination works in 1.0.6 it doesn't mean it will work robustly in future Arduino versions. Although I think you will see why you have potential for problems, it would still be useful to see a verbose output of the problem before you rectify it. Please switch on "tools>visual micro>verbose messages", then click "Build>clean solution" then click Build and then email the output to info [at] visualmicro.com.

Thanks
« Last Edit: Nov 2nd, 2014 at 10:51pm by Tim@Visual Micro »  
Back to top
IP Logged
 
_oesile_
Newbies
*
Offline


Posts: 7
Joined: Nov 2nd, 2014
Re: multiple definition of only in visual micro
Reply #6 - Nov 3rd, 2014 at 9:01am
Print Post  
I tried both solutions.

1) I added a grbl.h and grbl.c (also tried with cpp like you said), it doesn't work
2) I tried with qualifying #includes and it works!

But it woud be beter if you can compile the same source code with both IDEs.

I'm sending you right now the verbose output .
  
Back to top
 
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12189
Location: United Kingdom
Joined: Apr 10th, 2010
Re: multiple definition of only in visual micro
Reply #7 - Nov 3rd, 2014 at 7:29pm
Print Post  
Thanks very much for the great output examples. 

I see that Visual Micro is detecting the <grbl.h> include, but still going on to find the files in the Servo library (to resolve stepper.h). 

One question to save me some testing... Did you #include <grbl.h> above all other #includes?

Thanks again, that was very useful.

« Last Edit: Nov 3rd, 2014 at 9:43pm by Tim@Visual Micro »  
Back to top
IP Logged
 
_oesile_
Newbies
*
Offline


Posts: 7
Joined: Nov 2nd, 2014
Re: multiple definition of only in visual micro
Reply #8 - Nov 3rd, 2014 at 8:18pm
Print Post  
You're welcome! I´m developer too, so I know how difficult is this  Wink.

Yes, I did, like this:

#include <grbl.h>
#include <system.h>
#include <config.h>
#include <coolant_control.h>
#include <cpu_map.h>
#include <defaults.h>
#include <eeprom.h>
#include <gcode.h>
#include <limits.h>
#include <motion_control.h>
#include <nuts_bolts.h>
#include <planner.h>
#include <print.h>
#include <probe.h>
#include <protocol.h>
#include <report.h>
#include <serial.h>
#include <settings.h>
#include <spindle_control.h>
#include <stepper.h>

If you need something else, just let me know!
  
Back to top
 
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12189
Location: United Kingdom
Joined: Apr 10th, 2010
Re: multiple definition of only in visual micro
Reply #9 - Nov 3rd, 2014 at 9:50pm
Print Post  
Great thanks

When i said servo.h earlier I meant stepper.h which I see is in both the grbl folder and the stepper library folder.

So one last question.

Visual Micro is determining that you are using these libraries:-

Include Path 'C:\arduino\libraries\EEPROM'
Include Path 'C:\arduino\libraries\Stepper'
Include Path 'D:\Projects\Arduino\libraries\grbl'

Would you agree that the stepper library should not be used because you want to use the stepper.h from the grbl lib folder?

Thanks again.
« Last Edit: Nov 3rd, 2014 at 9:51pm by Tim@Visual Micro »  
Back to top
IP Logged
 
_oesile_
Newbies
*
Offline


Posts: 7
Joined: Nov 2nd, 2014
Re: multiple definition of only in visual micro
Reply #10 - Nov 4th, 2014 at 10:08am
Print Post  
Hi, yes, you are right I want to use the stepper.h  from the gbrl lib folder (also eeprom).
  
Back to top
 
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12189
Location: United Kingdom
Joined: Apr 10th, 2010
Re: multiple definition of only in visual micro
Reply #11 - Nov 4th, 2014 at 1:02pm
Print Post  
Great thanks

The bug in visual micro is that it is resolving the arduinoIDE/libraries before the sketchbook/user libraries. If it worked the other way around it would find gbrl first and would have resolved the correct files from gbrl.

We can see the problem in the verbose output you sent me:-

Include Path 'C:\arduino\libraries\EEPROM'
Include Path 'C:\arduino\libraries\Stepper'
Include Path 'D:\Projects\Arduino\libraries\grbl'

Should be:-

Include Path 'D:\Projects\Arduino\libraries\grbl'
Include Path 'C:\arduino\libraries\EEPROM'

I will also check my facts about Arduino 1.0.6 but from what I have said it should be clear that if in the future you add another user library that contains a stepper.h your sketch would easily break.

As I am sure you can imagine this is not an exact science and is a weak area of Arduino. I think it right that Visual Micro finds files based on library name and in the order specified by the #includes. This at least gives users a "known state of play"

Thanks again it has been a very useful exercise and expect the bug fixed in the next release later this week or next.

Obviously in the meantime either remove the Stepper library from c:\arduino\libraries or qualify your #includes with "libname/header.h"

#include "grbl/stepper.h"
« Last Edit: Nov 4th, 2014 at 5:56pm by Tim@Visual Micro »  
Back to top
IP Logged
 
_oesile_
Newbies
*
Offline


Posts: 7
Joined: Nov 2nd, 2014
Re: multiple definition of only in visual micro
Reply #12 - Nov 4th, 2014 at 5:51pm
Print Post  
Thank you for your help. I'm happy you found the bug. I'll be waiting for the new version
  
Back to top
 
IP Logged
 
gerber
Newbies
*
Offline


Posts: 1
Joined: Nov 25th, 2014
Re: multiple definition of only in visual micro
Reply #13 - Nov 25th, 2014 at 7:41pm
Print Post  
Hi, 

I don't see how this is resolved. The error was not duplication of stepper.h ( cf Stepper.h) but a double declaration of the __vector_16 variable in wiring.c

Quote:
core.a(wiring.c.o)*:In function `__vector_16'
wiring.c:multiple definition of `__vector_16'


Apparently this is in both grbl/stepper.c and core/wiring.c


This is  all about the sucky way that Arduino copies files to different locations, inserts headers and, as already noted, gets into fishing around in a somewhat ill-defined way for library headers. 

I am also trying to build grbl in Arduino IDE and have this same double declaration bug. 

I suppose grbl is one part of the problem since they seem to reuse a variable name that is already used in core Arduino. 

It may be that this was not in core when grbl was written about 5 years ago, don't know. 

I'm a little curious how OP managed to get this to build, because I would have thought that wiring.c would always get included. It is pretty indispensable to anything on Arduino.

[ BTW, I love the way my spelling checker suggest that Arduino is misspelt and proposes "arduous". That'd be about right. ]

  
Back to top
 
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12189
Location: United Kingdom
Joined: Apr 10th, 2010
Re: multiple definition of only in visual micro
Reply #14 - Nov 25th, 2014 at 8:23pm
Print Post  
Thanks for the info. Can you confirm it works the same when using the Arduino Ide?
  
Back to top
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint