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) Libraries and directories (Read 8542 times)
Henk Levels
Junior Member
**
Offline


Posts: 81
Joined: Sep 28th, 2015
Libraries and directories
Nov 24th, 2015 at 7:42am
Print Post  
Hello,

I'm rather new to this environment. I am using Arduino with Atmel studio 6.2 with a Visual Micro plugin. In the IDE Arduino directory I have a lot of libraries where some libraries have the same file, like ports.h etc, because I have downloaded libraries from others and put them in the Arduino IDE libraries tree.
When I compile my main code, how do I know which library file in what directory is being used when I include for example ports.h in my main file or the ports.h is called in an included file like JeeLib.h?
Where can I see, or change in ATMEL or Visual Micro the Library path that the compiler is using.
Thanks.
  
Back to top
 
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12191
Location: United Kingdom
Joined: Apr 10th, 2010
Re: Libraries and directories
Reply #1 - Nov 24th, 2015 at 10:36am
Print Post  
Hi,

This is generally an issue for Arduino but visual micro allows you to specify the library name in the #include

#include "MyLib\Time.h"
#include "MyLib\Spi.h"

or

If you don't use folder names in this way the order of includes can also be used to gain some additional control. This will probably find the spi.h in the mylib.h folder because mylib was #included first. However MyLib.h must be unique and the name of the lib folder

#include "MyLib.h"
#include "Spi.h"


« Last Edit: Nov 24th, 2015 at 10:37am by Tim@Visual Micro »  
Back to top
IP Logged
 
Henk Levels
Junior Member
**
Offline


Posts: 81
Joined: Sep 28th, 2015
Re: Libraries and directories
Reply #2 - Nov 24th, 2015 at 7:25pm
Print Post  
Hi tim,

thanks for your reaction and advice.
My question is more: when I have in my code #include <ports.h> and have more directories that contain ports.h, how do I know which directory is than used by the compiler.
thanks
  
Back to top
 
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12191
Location: United Kingdom
Joined: Apr 10th, 2010
Re: Libraries and directories
Reply #3 - Nov 24th, 2015 at 8:08pm
Print Post  
Hi Herik,

Ah I missed the last part. So you have the same file in multiple libraries which also need to be used at the same time in the same project/sketch.

I think that's difficult for Arduino. + Libraries don't really have an order other than the order in the main sketch which will cause the -I includes list in the compiler commands to be in that order. So in theory the .h of the library that is #included nearest the top of the sketch.ino

My limited understanding of how compilers resolve is that a .h in the same folder as the referencing source code will be found first, then the includes are scanned in the supplied order. 

You can see the compiler commands when you switch on "Visual Micro>Verbose Messages" and will see the order of the -I includes.

If you switch on "tools>options>visual micro>compiler>show build folder" a link to the temp build folder will appear in the compiler output after a build. CTRL+Click the link to view the temp build folder. The folder contains files with ".d" extensions. The .d files are simple text files outputted by the compiler and contain a list of .h dependencies/locations. Paths to all .h files that were used to build the .o object file. This gives you exact information about which .h files were actually used during build of each file.

I hope this helps.
  
Back to top
IP Logged
 
Henk Levels
Junior Member
**
Offline


Posts: 81
Joined: Sep 28th, 2015
Re: Libraries and directories
Reply #4 - Nov 24th, 2015 at 8:53pm
Print Post  
Hi Tim, thanks this helps
  
Back to top
 
IP Logged
 
Henk Levels
Junior Member
**
Offline


Posts: 81
Joined: Sep 28th, 2015
Re: Libraries and directories
Reply #5 - Nov 25th, 2015 at 6:54pm
Print Post  
Hi Tim,

When I put this in my code #include "LCD16x2\LCD16x2.h" 
It can be found. But then I get suddenly Wire.h can not be found?
When I change this twi.h can not be found.
When I change that chip.h can not be found.
I'm lost: What am I doing wrong?
« Last Edit: Nov 25th, 2015 at 6:59pm by Henk Levels »  
Back to top
 
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12191
Location: United Kingdom
Joined: Apr 10th, 2010
Re: Libraries and directories
Reply #6 - Nov 25th, 2015 at 7:50pm
Print Post  
Hi,

Your LCD library requires the Wire library. Don't add any #includes yourself but use the Visual Micro library selector to add them for you. Doing so should show you what was needed more easily. It should add #include "Wire.h"

You can't add includes for any lib sources that exist in the utility folder below libraries. They are private sources for sole use by the library.

You should also find examples in the micro explorer for the library you are using which will already contain the correct #includes
« Last Edit: Nov 25th, 2015 at 7:52pm by Tim@Visual Micro »  
Back to top
IP Logged
 
Henk Levels
Junior Member
**
Offline


Posts: 81
Joined: Sep 28th, 2015
Re: Libraries and directories
Reply #7 - Nov 25th, 2015 at 8:15pm
Print Post  
Hi Tim,

thanks for the Update but, I'm new, where can I find the Visual Micro Library Selector. I'm Using Atmel Studio 6.2
Online I see a different I see a different layout then I have (http://www.visualmicro.com/page/User-Guide.aspx?doc=Add-Libraries.html )
Please explain how to add
thanks for the help again.
« Last Edit: Nov 25th, 2015 at 8:27pm by Henk Levels »  
Back to top
 
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12191
Location: United Kingdom
Joined: Apr 10th, 2010
Re: Libraries and directories
Reply #8 - Nov 25th, 2015 at 8:58pm
Print Post  
In 6.2 it's on the project menu. "Project>Add/Import Arduino Library". You might need to select the project in the solution explorer before the menu items appear.
  
Back to top
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint