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 how to Add a user library (Read 3883 times)
Henk Levels
Junior Member
**
Offline


Posts: 81
Joined: Sep 28th, 2015
how to Add a user library
Aug 14th, 2016 at 9:40am
Print Post  
Hi There,

I'm rather new to this.
I have MS Visual Studio Community 2015 and the Visual Micro extension installed for use with a Arduino.
I have a library with a .h and .cpp file called StartupMonitor
I made a zip file of it and installed this with vMicro - Add Library - Install Arduino file
In the Solution explorer the library files .h and .cpp is found under src - micro-api-readonly - libraries. see screenshot attached
However when I compile the ino file it gives an error no such file or directory.
I checked the name and they seem ok.
Question
- what am I doing wrong?
- How can I best install the .h and .cpp files of a user library from within Visual micro
Thanks

« Last Edit: Aug 14th, 2016 at 9:47am by Henk Levels »  

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


Posts: 12204
Location: United Kingdom
Joined: Apr 10th, 2010
Re: how to Add a user library
Reply #1 - Aug 14th, 2016 at 1:23pm
Print Post  
Hi,

Arduino libraries are really simple things. All the installer does is unpack the zip into "mydocuments\arduino\libraries". "mydocuments\arduino" is called the sketchBook folder in Arduino speak and if you alter the folder in the options then the location of your \libraries must also be moved.

There isn't a registration system that is maintained when you install a library. The "mydocuments\arduino\libraries" folder is enumerated each time the ide starts or when you click "rescan". The scan of the physical folder determines which libraries are available. So you didn't need the zip and you can edit the source code in the "mydocuments\arduino\libraries\[your lib name]" folder.

The display of the library and arduino core sources  (src\micro-api-readonly) in your project does not affect compile. You have used the "Toggle Hidden Files" facility to make life easier when developing but the "readonly" section is for reference purposes only. 

It's useful you have toggled in the hidden files because I am going to assume visual micro added "StartupMonitor" folder in the Solution Tree automatically in which case we know the library sources exist in the correct location? 

If the lib sources exist in the correct location and the code fails to find them it must be a problem with the #include syntax. Did you use the "Add Library" facility to add the #include to the code? That ensure the correct syntax is used. I notice "StartupMonitor" has been #included with quotes and not chevrons. 

#include "StartupMonitor.h"

Should be <> ???
#include <StartupMonitor.h>

Make sense?
  
Back to top
IP Logged
 
Henk Levels
Junior Member
**
Offline


Posts: 81
Joined: Sep 28th, 2015
Re: how to Add a user library
Reply #2 - Aug 16th, 2016 at 8:18am
Print Post  
Hi,

Thanks for the explanation. But still have some questions.
In the configure IDE location the optional sketch book location is blank.
This means the libraries can be found in ....\Documents\Arduino\libraries. Correct?
However I noticed when I use Add Code the files are placed in the folder where the sketch is placed.
Why is the Add Code not placed in the libraries folder, also creating a subfolder with the same name as the .cpp and .h files, so I can reuse them in other projects as well?
I tried a lot as mentioned on the website, but it never compiles first time right, while the code is ok.
What is the best way to create user libraries that can be reused and use the Add Code possibility because of the use of intellisense.

Thanks in advance.
« Last Edit: Aug 16th, 2016 at 8:22am by Henk Levels »  
Back to top
 
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12204
Location: United Kingdom
Joined: Apr 10th, 2010
Re: how to Add a user library
Reply #3 - Aug 16th, 2016 at 12:19pm
Print Post  
Hi,

Your are getting confused. 

Please click "vMicro>Toggle Hidden Files" to remove the code shortcuts from your project.

Then consider how libraries work.

Add code relates to the current project only.

If you want to create libraries do that in a different project until you understand how arduino works
« Last Edit: Aug 16th, 2016 at 12:20pm by Tim@Visual Micro »  
Back to top
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint