VS Arduino | |
Visual Micro >> Project Guidance >> Using Library With Same Files Names as Libraries In Arduino SDK
https://www.visualmicro.com/forums/YaBB.pl?num=1402412911 Message started by Mike on Jun 10th, 2014 at 3:08pm |
Title: Using Library With Same Files Names as Libraries In Arduino SDK Post by Mike on Jun 10th, 2014 at 3:08pm
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 :D |
Title: Re: Using Library With Same Files Names as Libraries In Arduino SDK Post by Visual Micro on Jun 10th, 2014 at 3:20pm
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 |
Title: Re: Using Library With Same Files Names as Libraries In Arduino SDK Post by Mike on Jun 11th, 2014 at 1:26am
My apologies. Visual Studio 2012 w/ Arduino 1.0.5 - R2
|
Title: Re: Using Library With Same Files Names as Libraries In Arduino SDK Post by Visual Micro on Jun 11th, 2014 at 2:09am
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?
|
Title: Re: Using Library With Same Files Names as Libraries In Arduino SDK Post by Mike on Jun 11th, 2014 at 2:51am
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. |
Title: Re: Using Library With Same Files Names as Libraries In Arduino SDK Post by Visual Micro on Jun 11th, 2014 at 3:13am
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. |
Title: Re: Using Library With Same Files Names as Libraries In Arduino SDK Post by Mike on Jun 11th, 2014 at 3:39am
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 |
Title: Re: Using Library With Same Files Names as Libraries In Arduino SDK Post by Visual Micro on Jun 11th, 2014 at 2:11pm
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 |
VS Arduino » Powered by YaBB 2.6.12! YaBB Forum Software © 2000-2025. All Rights Reserved. |