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) Re: multiple definition of only in visual micro (Read 17896 times)
Doctor Wizard
Junior Member
**
Offline


Posts: 21
Location: Orange Park, FL
Joined: Dec 2nd, 2014
Re: multiple definition of only in visual micro
Dec 2nd, 2014 at 1:50am
Print Post  
I'm a noob to Visual Micro and I am having a similar problem.  Mine is in a 3rd party library: Adafruit_MCP23017.
It all compiles fine in the Arduino IDE, but in Visual Micro it returns a long list of errors.

Visual Studio Pro 2010
Visual Micro version from a week ago (licensed)
Arduino IDE 1.5.2 in I:\Arduino
My project folder is I:\Sketches\(whatever...)
3rd party libraries, including the troublemaker in I:\Sketches\libraries
Verbose output from build is attached.

Is there a way to tell Visual Micro to just use the hex files from the Arduino IDE's compile?

Note: I consider myself a damn good programmer -- in other languages such as C#.  My C++ skills are still a bit lacking.  I have enough trouble fixing my own bugs without having to fix a 3rd party's library.
  

Please Register or Login to the Forum to see File Attachments
Back to top
 
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12191
Location: United Kingdom
Joined: Apr 10th, 2010
Re: multiple definition of only in visual micro
Reply #1 - Dec 2nd, 2014 at 10:07am
Print Post  
Hi,

You don't need to mess about changing any lib code.

The arduino ide 1.5 beta has gone through a number of changes with libraries in terms of search path order and structure. let's first understand the issue...

1) What #imports do you have in your sketch
2) Please switch on file>preferences>verbose compile in the arduino ide. Then post the build output.

Thanks

edit: I am not sure what good would using the hex from the arduino ide do? However I can say we will resolve this quite easily. Looking forward to the additional info requested above. thanks
« Last Edit: Dec 2nd, 2014 at 5:09pm by Tim@Visual Micro »  
Back to top
IP Logged
 
Doctor Wizard
Junior Member
**
Offline


Posts: 21
Location: Orange Park, FL
Joined: Dec 2nd, 2014
Re: multiple definition of only in visual micro
Reply #2 - Dec 3rd, 2014 at 1:30am
Print Post  
Verbose build output from Visual Micro / Studio is in the zip file attached to the first post.
Verbose build output from the Arduino IDE is in the zip file attached to this post.

#includes are:
FastLED.h -- 3rd party library for WS2801, 2811, 2812, "NeoPixels" etc.
EEPROMEx.h -- EEPROM wrapper, 'nuf said.
DebugUtils.h -- defines wrapping Serial.Print for debugging  (in the Arduino environment where I don't have your debugger)
Wire.h -- For I2C, which is the interface to the Adafruit LCD display
Adafruit_MCP23017.h -- Adafruit's library for the MCP23017 I2C digital port expander IC.
Adafruit_RGBLCDShield.h -- Adafruit's library for their shield with an LCD with an RGB backlight, and navigation buttons, all controlled via I2C using an MCP23017.
  

Please Register or Login to the Forum to see File Attachments
Back to top
 
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12191
Location: United Kingdom
Joined: Apr 10th, 2010
Re: multiple definition of only in visual micro
Reply #3 - Dec 3rd, 2014 at 3:35pm
Print Post  
Thanks for the info.

I will look at it in more detail shortly but need the following.

1)
The visual micro output you posted was not made after clicking "build>clean solution" which means that most of the build detail is missing because a previously cached version was used.

2)
I assume you are saying that DebugUtils.h is only required when you build in the arduino ide?

3)
Please try prefixing the lib names with the name of the library folder they relate to. You don't need this ongoing but a useful test.

Code
Select All
#include "FastLED/FastLED.h"
..EEPROMEx/EEPROMEx.h
..DebugUtils/DebugUtils.h
..Wire/Wire.h
..Adafruit_MCP23017/Adafruit_MCP23017.h
..Adafruit_MCP23017/Adafruit_RGBLCDShield.h
 



In my example I might have used the wrong folder names. Please check them thanks. please send the new vm build output prior to prefixing library includes
« Last Edit: Dec 3rd, 2014 at 3:37pm by Tim@Visual Micro »  
Back to top
IP Logged
 
Doctor Wizard
Junior Member
**
Offline


Posts: 21
Location: Orange Park, FL
Joined: Dec 2nd, 2014
Re: multiple definition of only in visual micro
Reply #4 - Dec 3rd, 2014 at 6:14pm
Print Post  
OK, adding the paths to the libraries worked and got it to compile in Visual Micro / Studio.  However, that prevents it from compiling in the Arduino IDE.  Normally, I wouldn't care, but this happens to be a shared project so my co-programmer needs to be able to compile it in the Arduino IDE as well.

DebugUtils.h is a small little file that #defines DEBUG_Print as either Serial.print - for debugging, or as nothing for the release version.

Zip file attached contains 3 items:  DebugUtils.h, the verbose output from a successful clean build with the paths added to the libraries, and the verbose output from an unsuccessful clean build without the paths added to the libraries.  I can send the main sketch too if you'd like, but best as I can tell it is free of errors and even most warnings.  Aw what the heck, I'm attaching it anyway.

I'm guessing this is all just a missing or incorrect path in an option somewhere.  But which/where?  They all look good to me (but I'm a noob to Visual Micro).
  

Please Register or Login to the Forum to see File Attachments
Back to top
 
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12191
Location: United Kingdom
Joined: Apr 10th, 2010
Re: multiple definition of only in visual micro
Reply #5 - Dec 3rd, 2014 at 7:56pm
Print Post  
Thanks very much for sending all the info especially the sketch.ino which shows the issue.

This is not something you have configured incorrectly, arduino libraries have a few abnormalities which have changed throughout their various application versions, especially between arduino 1.5>1.5.3 and again within 1.5.4+. These issues are normally related to libraries that don't contain a .h of the same name. Notice that paths are not specified int he code for arduino libraries so conflicting names within different libraries are more difficult to resolve in the case of libraries without [libraryname.h] files. It can be difficult to know which library users are hoping to use.

In this case this is not the issue. The issue is that Visual Micro believes that the LiquidCrystal_I2C needs to be used. In your sketch code the LCD.h and LiquidCrystal_I2C.h libraries are included but within conditional #if statements like this ...

Code
Select All
#elif (LCD_CONFIG == LCD_GENERIC_I2C)
  // Using DFRobot or other cheap Chinese generic backpack
  #include <LCD.h>
	#include <LiquidCrystal_I2C.h> 



Historically Arduino has attempted to compile the libraries regardless of their "condition" in the code. This is because of the way Arduino finds #included libraries from within the code, it uses regex (string splitting) expressions before the compile.

From your report, it sounds like the Arduino Ide team have managed to workout which libs are actually included ignoring ones within invalid #if statements. We can also see in the verbose build from the arduino ide that it has not attempted to compile the lcd or i2 libraries. 

I guess they are now looking at compiler defines within the regex lib filtering but without more exploration I can not be sure.

It certainly explains a few things and I will look, at the weekend, how the arduino ide can be ignoring these includes. I must have missed this change on the arduino dev forum.

Thanks very much for such complete answers, it's a real time saver for me. I'll post with a new release over the next week or so.
  
Back to top
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12191
Location: United Kingdom
Joined: Apr 10th, 2010
Re: multiple definition of only in visual micro
Reply #6 - Dec 3rd, 2014 at 10:50pm
Print Post  
Think I have found the problem.

Visual Micro resolve libraries sketchbook/libraries first then arduinoide/libraries. Notice in the two different verbose outputs that the LiquidCrystal library is being resolved from different locations.

This means that in addition to the LiquidCrystal library installed with the arduino ide you also have one in yoru sketchbook/libraries folder. Remove the one in your sketchbook/libraries and you should get the same compile as you get in the arduino ide.

It would also be helpful if you unpacked the zip of arduino 1.5.8 to see if your sketch still compiles, if it does please zip and email the liquidcrystal library from your sketchbook folder.

Your sketch compiles okay for me without the lib
  
Back to top
IP Logged
 
Doctor Wizard
Junior Member
**
Offline


Posts: 21
Location: Orange Park, FL
Joined: Dec 2nd, 2014
Re: multiple definition of only in visual micro
Reply #7 - Dec 5th, 2014 at 4:24pm
Print Post  
OK, Tim, so at this point I have to include the paths with the 3rd party libraries to get it to compile in Visual Micro, and take them back out to get it to compile in the Arduino IDE.

I'm currently working on a shared project with someone else right now so that's a pain in the butt.  Is there a compiler definition or an environment variable exclusive to Visual Micro so I could do something like:
Code (C++)
Select All
#if defined (__VISUAL_MICRO__)
#include <Wire/Wire.h>
#else
#include <Wire.h>
#endif 

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


Posts: 12191
Location: United Kingdom
Joined: Apr 10th, 2010
Re: multiple definition of only in visual micro
Reply #8 - Dec 5th, 2014 at 4:56pm
Print Post  
I think that it's only the LiquidCrystal library you have to add a path for.

I believe that the correct way for arduino to work is to allow users to override system libraries by adding a library of the same name to the sketchbook/libraries location. This is what you have done with the LiquidCrystal library.

I want to check but I think this is a bug in arduino 1.5.2 that does not resolve the user sketchbook libraries as a priority.

It would be useful if you could zip and email your LiquidCrystal library from the sketchbook just so that I can replicate and be 100% sure.

If I am right then your current design will fail in future arduino versions. I have to say, although feel free to ignore me, that the Arduino 1.5.2 beta you are using is a strange choice of ide because so much was up in the air at that stage of the 1.5.x life cycle.

One thing that would be very interesting is to see what happens if you remove the LiquidCrystal library from below the arduino 1.5.2/libraries folder. This would force 1.5.2 to use the version in your sketch folder and then I would expect to see the same error as you see in visual micro.
  
Back to top
IP Logged
 
Doctor Wizard
Junior Member
**
Offline


Posts: 21
Location: Orange Park, FL
Joined: Dec 2nd, 2014
Re: multiple definition of only in visual micro
Reply #9 - Dec 7th, 2014 at 1:17am
Print Post  
You were close, but not quite.  Problem was Adafruit_MCP23017 library.  I now have it working / compiling in both environments:

Removed folder name from FastLED, Wire, and EEPROMEx library #includes.

Removed folder name from Adafruit_RGBLCDShield.h #include.

Kept folder name for Adafruit_MCP23017.h library which is actually in the Adafruit_RGBLCDShield folder.

Tried moving the Adafruit_MCP23017.h library to it's own folder with a matching name, but that didn't work.

Also Note: There WAS a LiquidCrystal library in the libraries folder in the Arduino IDE folder.  It must have come with the IDE.  Only other library in there was the SD lib.  There was an older version in Skecthes\Arduio\libraries.  Moved the newer LiquidCrystal and SD libraries out of I:\Arduino\libraries and into I:\Sketches\Arduino\libraries.

So I'm good-to-go at this point, at least for now!
  
Back to top
 
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12191
Location: United Kingdom
Joined: Apr 10th, 2010
Re: multiple definition of only in visual micro
Reply #10 - Dec 7th, 2014 at 1:37am
Print Post  
Great, thanks very much for the useful info.

Sorry I couldn't quite hit the target with that one, I'm going to try to replicate it but good to hear it's working.
  
Back to top
IP Logged
 
Doctor Wizard
Junior Member
**
Offline


Posts: 21
Location: Orange Park, FL
Joined: Dec 2nd, 2014
Re: multiple definition of only in visual micro
Reply #11 - Dec 7th, 2014 at 6:46pm
Print Post  
The problem appears only to be with the Adafruit_RGBLCDShield library, and apparently only because it in turn uses the Adafruit_MCP23017 library, which is in the same folder as RGBLCDShield.  So the question is: Why does it compile without the path in the Arduino IDE and not in Visual Micro's?

Something to do with #includes and path searching...
  
Back to top
 
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12191
Location: United Kingdom
Joined: Apr 10th, 2010
Re: multiple definition of only in visual micro
Reply #12 - Dec 7th, 2014 at 7:29pm
Print Post  
Good question that's what I was asking myself and also asking myself if arduino 1.5.8 does the same as 1.5.2 or vm.

Can you point me to where you got the liquidcrystal library. I need to replicate the issue.

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


Posts: 12191
Location: United Kingdom
Joined: Apr 10th, 2010
Re: multiple definition of only in visual micro
Reply #13 - Dec 8th, 2014 at 12:06am
Print Post  
Okay! So while arduino libraries often suffer from various minor issues everything I have said is rubbish in this case and I think I've wasted your time.

Please try the latest visual micro beta http://www.visualmicro.com/downloads/beta/arduinoforvisualstudio.msi

I found an issue in the build process in the way new format arduino libraries were being copied to the temp builder folder. All new format root library sources were incorrectly copied to buildFolder\src instead of buildFolder\libraryName. 

nb: With new format libraries you will see the sources of new format libraries, such as liquidcrystal, are located in \LIbraries\LibraryName\Src

I also found that the visual micro menu "Project>Show sketch core and library sources" wasn't working correctly for new format libraries. This is not a crucial visual micro feature but it does help to clearly show where library sources are resolved from. This is especially useful with libraries like the adafruit_RGBLCDShield which also contains LiquidCrystal.cpp/.h files.

As an aside, I tested arduino 1.5.8 and 1.5.2. 1.5.8 resolves libraries in the sketchbook/libraries folder in preference to libraries of the same name in the "ide/libraries" folder.

Thanks very much for putting so much effort into this!

The beta will be the official release during the next week but for now, when it runs for the first time, a message will be appear informing you of an update being available. please ignore the message.
« Last Edit: Dec 8th, 2014 at 12:07am by Tim@Visual Micro »  
Back to top
IP Logged
 
Doctor Wizard
Junior Member
**
Offline


Posts: 21
Location: Orange Park, FL
Joined: Dec 2nd, 2014
Re: multiple definition of only in visual micro
Reply #14 - Dec 8th, 2014 at 3:39pm
Print Post  
Attached:
The Liquid Crystal Library, which as I mentioned, was only 1 of 2 libraries included with the Arduino IDE ver 1.5.2.  The libraries were in I:\Arduino\libraries but when we started having compile problems with Visual Micro, I moved them to I:\Sketches\Arduino\libraries.

The Adafruit_RGBLCDShield library, as downloaded from GIT about a month ago.  The Adafruit_MCP23017 library, as mentioned, is also in this same folder.  I keep it with all my other 3rd party libraries (including Liquid Crystal, above) in I:\Sketches\Arduino\libraries\<library name>.  Note that the RGBLCDShield folder does NOT contain its own copy of Liquid Crystal.

I haven't verified this but: I expect RGBLCDShield calls LiquidCrystal_I2C, which in turn calls LiquidCrystal and Wire.

I tried Arduino IDE 1.5.8 a while back and it had some idiosyncrasies, although at this point I don't remember what they were, that's why I stuck with 1.5.2, but I will go ahead and try 1.5.8 again with your latest Visual Micro beta and get back to you.

BTW: I am LOVING Visual Micro!  Been wanting to get out of the Arduino IDE and into a better one for quite a while.  And I'm already familiar with Visual Studio because I do C# desktop apps for Windows.  Eclipse looked nice, but I couldn't figure parts of it out.  Will have to figure out Eclipse eventually I guess, as I have taken an interest in embedded linux on microcontrollers such as the Pi and Beaglebone.
  

Please Register or Login to the Forum to see File Attachments
Back to top
 
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12191
Location: United Kingdom
Joined: Apr 10th, 2010
Re: multiple definition of only in visual micro
Reply #15 - Dec 8th, 2014 at 3:43pm
Print Post  
Thanks for the info. Good luck when you do get to Eclipse Smiley

Did you try the latest Visual Micro beta? Did it resolve the issue with your standard setup?
  
Back to top
IP Logged
 
Doctor Wizard
Junior Member
**
Offline


Posts: 21
Location: Orange Park, FL
Joined: Dec 2nd, 2014
Re: multiple definition of only in visual micro
Reply #16 - Dec 8th, 2014 at 5:13pm
Print Post  
Out of the frying pan, into the fire...

Installed Arduino IDE 1.5.8, and latest Visual Micro Beta.

The path issue has now moved, it is no longer with Adafruit_RGBLCDShield (perhaps because the compiler is not getting that far) and now it has an issue (Error: No Such File or Directory) with the EEPROMEx library, on line 23, where it includes EEPROM.

However, it no longer compiles in the Arduino IDE either.  Same error (No Such File) with EEPROMex on line 23 where it includes EEPROM.

Nothing else has changed.  I renamed the directory for 1.5.2 and put 1.5.8 in the folder name (I:\Arduino) that I had originally used for 1.5.2.

Went back to 1.5.2 (renamed folders again accordingly) (but kept your latest beta of VM) and it once again compiles in the Arduino IDE (with or without the path on the Adafruit library) but still does not compile in Visual Micro (without the path, but does compile with the path).

I'm sure you are anxious to track this down, but I have a workaround so you don't need to be in a hurry on my account.  I'll be happy to test any fixes you come up with on my end though.
  
Back to top
 
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12191
Location: United Kingdom
Joined: Apr 10th, 2010
Re: multiple definition of only in visual micro
Reply #17 - Dec 8th, 2014 at 5:39pm
Print Post  
Thanks.

Out of interest does your sketch #include EEPROM or EEPROMex

Thanks
  
Back to top
IP Logged
 
Doctor Wizard
Junior Member
**
Offline


Posts: 21
Location: Orange Park, FL
Joined: Dec 2nd, 2014
Re: multiple definition of only in visual micro
Reply #18 - Dec 9th, 2014 at 9:39pm
Print Post  
Yes.

It's in my 3rd party libraries folder, I:\Sketches\Arduino\libraries\EEPROMEx  (I just downloaded the newest version recently.)

On line 23 it has #include EEPROM.h

Which is in I:\Sketches\Arduino\libraries\EEPROM

Note that the include uses  and does not include the path, and that EEPROMEx and EEPROM are each in their own folders.**

Compiles in Arduino IDE 1.5.2 but not in 1.5.8.  Visual Micro compiles likewise according to which Arduino IDE is installed.


** (Unlike our previous troublemakers, Adafruit_RGBLCDShield and AdaFruit_MCP23017 which were in the same folder and #included using quotes.  And which may still be a troublemaker if it gets past EEPROM.)
  
Back to top
 
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12191
Location: United Kingdom
Joined: Apr 10th, 2010
Re: multiple definition of only in visual micro
Reply #19 - Dec 9th, 2014 at 10:11pm
Print Post  
Sorry to hear that.

As I said earlier, there have been major changes to how Arduino works in the beta 1.5 since 1.5.2. 

Unfortunately it's always been a hti and miss area for arduino because of the lack of path name against lib files. Many users had the issue of the wrong files being resolved so a new slightly improved set of rules were created by the arduino dev team but the eeprom.h in the eepromex folder will cause the compilers to think the eeprom library needs to be included in the compile.

The order of the includes is also important, forcing the files in certain libraries to be resolved first. This is true for visual micro and I suspect for the arduino ide.

So you might resolve the issue by moving #include <eeprom.h> to below #include <eepromex.h>

  
Back to top
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint