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 Creating New Library and use it in a shetch (Read 1409 times)
The_Specialist
Full Member
***
Offline


Posts: 227
Joined: Jul 1st, 2020
Creating New Library and use it in a shetch
May 13th, 2022 at 2:04pm
Print Post  
I have created a library in my library folder. By creating new project at start up and then new library.

Now I having an issue to imported in to a shetch. Why? Because microsoft create an additonal folder on top. This is where my library path looks like.

G:\Documents\Visual Studio 2019\Arduino\libraries\URLStreamSimple\URLStreamSimple\src\URLStreamSimple.h

In the library.properties file I can add 

includes=URLStreamSimple\URLStreamSimple\src\URLStreamSimple.h

But the properties file will never be find because the additional folder URLStreamSimple on top of the hierarchy where the .sln is located.

How can I solve this?
« Last Edit: May 13th, 2022 at 2:10pm by The_Specialist »  
Back to top
 
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12076
Location: United Kingdom
Joined: Apr 10th, 2010
Re: Creating New Library and use it in a shetch
Reply #1 - May 13th, 2022 at 2:16pm
Print Post  
We never specify paths for Arduino library files. In your example you have an \src folder below your library. That means it is a version 2 arduino library. The \src folder is treated as the lib folder therefore you should keep things clean like this.

Code
Select All
includes=URLStreamSimple.h 



Note: The "includes" property only affects the "#includes" that are auto added to your code when selecting the library. In your example it is very simple. You do not need the includes= in the library.properties
« Last Edit: May 13th, 2022 at 2:17pm by Tim@Visual Micro »  
Back to top
WWW  
IP Logged
 
The_Specialist
Full Member
***
Offline


Posts: 227
Joined: Jul 1st, 2020
Re: Creating New Library and use it in a shetch
Reply #2 - May 13th, 2022 at 3:01pm
Print Post  
Ok, that I did, but I can't do this in my shetch

#include "URLStreamSimple.h"
URL-Player-Simple.ino: 20:10: fatal error: URLStreamSimple.h: No such file or directory

And I can not add it from the vm menu -> add library because of that solution folder on top.


Code
Select All
#include <G:\Documents\Visual Studio 2019\Arduino\libraries\URLStreamSimple\URLStreamSimple\src\URLStreamSimple.h>

and this he will find, but then I get some building errors

collect2.exe*: error: ld returned 1 exit status

G:\Documents\Visual Studio 2019\Arduino\libraries\URLStreamSimple>dir /s
 De volumenaam van station G is Downloads
 Het volumenummer is CE9D-0063

 Map van G:\Documents\Visual Studio 2019\Arduino\libraries\URLStreamSimple

This is the complete list of my files

13/05/2022  11:17    <DIR>          .
13/05/2022  11:17    <DIR>          ..
13/05/2022  16:44    <DIR>          URLStreamSimple
13/05/2022  11:17               589 URLStreamSimple.sln
               1 bestand(en)              589 bytes

 Map van G:\Documents\Visual Studio 2019\Arduino\libraries\URLStreamSimple\.vs

13/05/2022  11:17    <DIR>          URLStreamSimple
               0 bestand(en)                0 bytes

 Map van G:\Documents\Visual Studio 2019\Arduino\libraries\URLStreamSimple\.vs\U
RLStreamSimple

13/05/2022  11:17    <DIR>          .
13/05/2022  11:17    <DIR>          ..
13/05/2022  15:58    <DIR>          v16
               0 bestand(en)                0 bytes

 Map van G:\Documents\Visual Studio 2019\Arduino\libraries\URLStreamSimple\.vs\U
RLStreamSimple\v16

13/05/2022  15:58    <DIR>          .
13/05/2022  15:58    <DIR>          ..
13/05/2022  16:58           253.952 Browse.VC.db
13/05/2022  15:58            32.768 Browse.VC.db-shm
13/05/2022  16:58                 0 Browse.VC.db-wal
13/05/2022  11:18    <DIR>          ipch
               3 bestand(en)          286.720 bytes

 Map van G:\Documents\Visual Studio 2019\Arduino\libraries\URLStreamSimple\.vs\U
RLStreamSimple\v16\ipch

13/05/2022  11:18    <DIR>          .
13/05/2022  11:18    <DIR>          ..
13/05/2022  11:20    <DIR>          AutoPCH
               0 bestand(en)                0 bytes

 Map van G:\Documents\Visual Studio 2019\Arduino\libraries\URLStreamSimple\.vs\U
RLStreamSimple\v16\ipch\AutoPCH

13/05/2022  11:20    <DIR>          .
13/05/2022  11:20    <DIR>          ..
13/05/2022  11:18    <DIR>          aaf09fdbd659e6b3
13/05/2022  11:20    <DIR>          fd3cfd0deea080f8
               0 bestand(en)                0 bytes

 Map van G:\Documents\Visual Studio 2019\Arduino\libraries\URLStreamSimple\.vs\U
RLStreamSimple\v16\ipch\AutoPCH\aaf09fdbd659e6b3

13/05/2022  11:18    <DIR>          .
13/05/2022  11:18    <DIR>          ..
               0 bestand(en)                0 bytes

 Map van G:\Documents\Visual Studio 2019\Arduino\libraries\URLStreamSimple\.vs\U
RLStreamSimple\v16\ipch\AutoPCH\fd3cfd0deea080f8

13/05/2022  11:20    <DIR>          .
13/05/2022  11:20    <DIR>          ..
               0 bestand(en)                0 bytes

 Map van G:\Documents\Visual Studio 2019\Arduino\libraries\URLStreamSimple\URLSt
reamSimple

13/05/2022  16:44    <DIR>          .
13/05/2022  16:44    <DIR>          ..
13/05/2022  14:30               508 keywords.txt
13/05/2022  16:44               241 library.properties
13/05/2022  11:34               140 readme.txt
13/05/2022  17:10    <DIR>          src
13/05/2022  11:22             1.302 URLStreamSimple.vcxitems
13/05/2022  11:22             1.207 URLStreamSimple.vcxitems.filters
               5 bestand(en)            3.398 bytes

 Map van G:\Documents\Visual Studio 2019\Arduino\libraries\URLStreamSimple\URLSt
reamSimple\src

13/05/2022  17:10    <DIR>          .
13/05/2022  17:10    <DIR>          ..
13/05/2022  17:10             5.045 URLStreamSimple.cpp
13/05/2022  17:10               805 URLStreamSimple.h
               2 bestand(en)            5.850 bytes

     Totaal aantal weergegeven bestanden:
              11 bestand(en)          296.557 bytes
              26 map(pen)  2.841.624.215.552 bytes beschikbaar

 

« Last Edit: May 13th, 2022 at 4:29pm by Tim@Visual Micro »  
Back to top
 
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12076
Location: United Kingdom
Joined: Apr 10th, 2010
Re: Creating New Library and use it in a shetch
Reply #3 - May 13th, 2022 at 4:35pm
Print Post  
You must not use paths when adding #includes for Arduino libraries.

Let me explain the way Arduino works. I suggest we stick to standard Arduino and then when you understand how it works you might consider some more advanced Visual Micro features. For now this is Arduino.

Standard Arduino

User installed libraries will be located under the [SketchBook]/Libraries folder. The SketchBook folder is usually "Documents\Arduino".

Therefore, you should create or move you library to "Documents\Arduino\Libraries\URLStreamSimple"

If you have not altered the default then after you move your library to that location and click rescan or restart then your library will be used as follows:-

Code
Select All
#include <URLStreamSimple.h> 



note: You probably need to remove the library you have created from your solution and re-add it after you have copied it to the correct location.

If you still have problems after that then please follow the guide in the yellow box above.


« Last Edit: May 13th, 2022 at 4:36pm by Tim@Visual Micro »  
Back to top
WWW  
IP Logged
 
The_Specialist
Full Member
***
Offline


Posts: 227
Joined: Jul 1st, 2020
Re: Creating New Library and use it in a shetch
Reply #4 - May 14th, 2022 at 12:22pm
Print Post  
So all my solution files have to end up in the same folder, that's what you are saying.

I did that and it's working. Don't know it, if I create other library's in that folder...
« Last Edit: May 14th, 2022 at 12:25pm by The_Specialist »  
Back to top
 
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12076
Location: United Kingdom
Joined: Apr 10th, 2010
Re: Creating New Library and use it in a shetch
Reply #5 - May 14th, 2022 at 7:47pm
Print Post  
Hopefully you now understand how to use Arduino libraries in a way that is compatible with the Arduino IDE. This involves a folder for each library placed below your Arduino [sketchbook]/libraries folder.

In Visual Micro you have more capability. 

You can create a library wherever you want BUT it will still be #included without path, the way I have shown you in this post. 

When you add a shared library (or shared code) project to the solution you also need to right click the "References" node below the Arduino project(s). Then click "Add Reference". 

On the "Add References" window there is a tab called "Shared Projects". That is where you add or remove references to your shared projects.

Does this make sense?

  
Back to top
WWW  
IP Logged
 
The_Specialist
Full Member
***
Offline


Posts: 227
Joined: Jul 1st, 2020
Re: Creating New Library and use it in a shetch
Reply #6 - May 15th, 2022 at 8:06am
Print Post  
Yes it does. It is solved now!

For more information how to include libraries into a cpp file:

https://www.visualmicro.com/forums/YaBB.pl?num=1652515966/4#4

For not having the addition folder on top this is how it can be solve.
« Last Edit: May 15th, 2022 at 8:30am by The_Specialist »  

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


Posts: 12076
Location: United Kingdom
Joined: Apr 10th, 2010
Re: Creating New Library and use it in a shetch
Reply #7 - May 15th, 2022 at 3:01pm
Print Post  
Great we are working on improving the docs for advanced users. Will review.
  
Back to top
WWW  
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint