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 Using Library With Same Files Names as Libraries In Arduino SDK (Read 10381 times)
Mike
Junior Member
**
Offline


Posts: 13
Joined: Jun 10th, 2014
Using Library With Same Files Names as Libraries In Arduino SDK
Jun 10th, 2014 at 3:08pm
Print Post  
I am trying to run a library called GSMSHIELD. In this library there is a gsm.h and gsm.cpp. 

However, Arduino has a library in its SDK package I believe called "GSM" which have some of the same file names as GSMSHIELD. When I look at my external dependencies, I have multiple variants of the same files. How do I get the compiler to ignore the core version? Moreover, when I right click on an include from "GSMSHIELD" lib it takes me to a file from "GSM" lib.  This can make things very troublesome b/c I have no idea what file is being used when my program compiles.

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


Posts: 12071
Location: United Kingdom
Joined: Apr 10th, 2010
Re: Using Library With Same Files Names as Libraries In Arduino SDK
Reply #1 - Jun 10th, 2014 at 3:20pm
Print Post  
Hi,

If using Visual Studio you can click "Project>Show all sketch files" this should include the correct lib files in your sketch and will not break compilation. The feature is not yet available in Atmel Studio.

In visual studio and atmel studio you also have various other options or points of interest

1) Intellisense when typing should show the correct values
2) Right click an #include and then click "Goto Implementation" (Alt+G)
3) Right click any code then click "Goto Implementation" (Alt+G)
4) Right click and code then click "Find references"

Hopefully these items help but can you please confirm which Ide you are using so we can explore this some more.

Thanks
  
Back to top
WWW  
IP Logged
 
Mike
Junior Member
**
Offline


Posts: 13
Joined: Jun 10th, 2014
Re: Using Library With Same Files Names as Libraries In Arduino SDK
Reply #2 - Jun 11th, 2014 at 1:26am
Print Post  
My apologies.  Visual Studio 2012 w/ Arduino 1.0.5 - R2
  
Back to top
 
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12071
Location: United Kingdom
Joined: Apr 10th, 2010
Re: Using Library With Same Files Names as Libraries In Arduino SDK
Reply #3 - Jun 11th, 2014 at 2:09am
Print Post  
Okay in Vs it is F12 to jump to definition but the "include all sketch files" should work well. The class explorer should also only show the correct libraries?
  
Back to top
WWW  
IP Logged
 
Mike
Junior Member
**
Offline


Posts: 13
Joined: Jun 10th, 2014
Re: Using Library With Same Files Names as Libraries In Arduino SDK
Reply #4 - Jun 11th, 2014 at 2:51am
Print Post  
Here is a screenshot.  You can see the double inclusion for the GSM.h.  Similarly all of those "GSM3XXXX..." files are from the "GSM" library, and not the "GSMSHIELD" library that i am using.  Note: I did not select the GSM library into my project.

Where do I have to go to remove/unlink the "GSM" library from my project?  I tried to edit the solution file manually but it did not seem to help.   

Currently, the only work around I have been able to find it to totally delete the "GSM" library from the library folder and then create my project.

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


Posts: 12071
Location: United Kingdom
Joined: Apr 10th, 2010
Re: Using Library With Same Files Names as Libraries In Arduino SDK
Reply #5 - Jun 11th, 2014 at 3:13am
Print Post  
Hi

Because it isn't possible to specify library paths in an arduino project there are certain rules to bear in mind. The entire library system has been overhauled 3 times in the past year by the arduino team so if we can improve visual micro we will.

Here are some things that might help ...

Normally Arduino libraries have a .h file of the same name as a library folder. This makes library resolution much more accurate. For example #include "GSMSHIELD.h". Is there a GSMSHIELD.h in the GSMSHIELD library? You see that all standard Arduino libraries adhere to this rule of a .h and a lib folder being the same. If your lib had a gsmshield.h then the library resolver would find all .h files from the GSMSHIELD library in preference to other libraries. One solution is that you could create an empty .h and include it in the sketch.

The resolver looks for "[sketchbook folder]/libraries" in preference to libraries stored under the arduino ide. This can be used to some advantage sometimes.

Because of this "hole" in the Arduino compiler design Visual Micro also allows you to specify the exact library by preceding #includes with the library name:- 

"libraryName\header.h"
"GSMSHIELD\gsm.h"

The latter suggestion will not work in the arduino ide but gives you complete control. The order of the #includes can also be used to control the resolution of libraries so put your #includes that do not resolve to multiple libraries first or put a fully qualified ("GSMSHIELD\gsm.h") reference at the top so that other .h files can be resolved from the named library.

In short, visual micro does it's best to find library sources but when duplicates exist and a LibraryName.h does not exist then things need a little care and attention.

I hope this makes sense.
  
Back to top
WWW  
IP Logged
 
Mike
Junior Member
**
Offline


Posts: 13
Joined: Jun 10th, 2014
Re: Using Library With Same Files Names as Libraries In Arduino SDK
Reply #6 - Jun 11th, 2014 at 3:39am
Print Post  
No there is not a GSMSHIELD.h.  I will try your suggestion.

What you say makes sense regarding including the path name.

Lets say MicroVisual has already included the "GSM" library after trying to compile.  What proper steps do I need to take to remove it from the project?  I notice that even if I were to delete the entire "GSM" library, the project still tries to include it.

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


Posts: 12071
Location: United Kingdom
Joined: Apr 10th, 2010
Re: Using Library With Same Files Names as Libraries In Arduino SDK
Reply #7 - Jun 11th, 2014 at 2:11pm
Print Post  
gsm is being included because of the #include "gsm.h" in your sketch. 

Every compile re-looks at the includes to establish the build requirement.

It is possible to clear the compiler cache with "Build>Clean Solution" but this is not required and is not the problem. 

The problem is simply that a library folder containing gsm.h is being discovered before the GSMShield folder.

Hopefully my previous post explains ways to resolve the conflicting lib source file names
  
Back to top
WWW  
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint