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 Workflow for creating a new Arduino Library? (Read 2875 times)
Zenra
Junior Member
**
Offline


Posts: 29
Joined: Mar 8th, 2017
Workflow for creating a new Arduino Library?
Mar 30th, 2021 at 2:20am
Print Post  
I’ve used Visual Micro for years but only recently taken an interest in using the environment to author libraries.  I am having trouble, though, understanding the usefulness of the “New Arduino Library” option creating a new Visual Micro project in VS2019.  When I start a new solution, or add a “New Arduino Library” project to an existing solution, I get a project with *.h and *.CPP files, which is fine, but with no configured references or means to build the project. I can add another project to the solution to test the library under development, but even after including the library in that test project Intelli-Sense doesn’t work in the library source files, which is very frustrating.

I assume that I must be mis-using the new library project option, so am looking for instruction for using it properly.  I like working in Visual Micro a lot, and as the scope of the projects I work on continues increasing to include ESP32 boards and more complex applications I would really like to leverage ways to share code modules and build libraries in this environment, for all the usual reasons. I will appreciate advice on workflow, directions or explanation for how to develop Arduino libraries using Visual Micro, etc.

Thanks for a great tool, and for all the experience and expertise shared here.

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


Posts: 12071
Location: United Kingdom
Joined: Apr 10th, 2010
Re: Workflow for creating a new Arduino Library?
Reply #1 - Mar 30th, 2021 at 2:34am
Print Post  
Thanks for the question. There are a few points that might help you understand but feel free to ask for more info

1. An Arduino library is not a program, the library code can be referenced/used from an arduino program.

2. If your new library is created in your arduino "sketchbook/libraries" folder then the library will be accessible to all arduino ide and visual micro projects. After creating the library in the sketchbook folder, I suggest you click the "vMicro>General>Reload Toolchains" or re-Start the IDE. The arduino sketchbook/libraries folder is usually "documents/arduino/libraries"

3. In Visual Micro, if you have created a library outside of the arduino sketchbook/libraries folder and it is included as a project in a solution that also includes one of more arduino projects. Then for the Arduino project you can right click "References>Shared". The library will be displayed in the list, you can check the checkbox to include it in your arduino project. By adding a Reference to the library this way you can place libraries anywhere without being restricted to the official arduino library locations.

4) In all cases libraries are #included in code, when required, using the normal arduino library include syntax which does not contains paths. For example:- "#include <MyLibHeader.h> as opposed to #include <../foo/MyLibHeader.h>

tip: If you use the "Clone" facility on the Visual Micro "Add Code> Library" menu, then you will be able to add a standard arduino library. Visual Micro will create a shared library project for the library you select and Visual Micro will  add the "Reference" described in 3). It might be a way to see a working example.

Does this help?
  
Back to top
WWW  
IP Logged
 
Zenra
Junior Member
**
Offline


Posts: 29
Joined: Mar 8th, 2017
Re: Workflow for creating a new Arduino Library?
Reply #2 - Mar 30th, 2021 at 12:59pm
Print Post  
Tim,

Thank you for the fast and thorough reply.

I think I understand well enough how Arduino libraries work and thanks to your description how VM handles them.  For me, your item 3 made the difference: Adding a reference to the library under development (which I placed in the same libraries folder with all the other libraries I've installed) as a "Shared Project" to another project I set up as a test bed for the library under development solved all the issues (e.g., duplicate modules found during linking, etc.).  I like this project structure because it allows me to develop the library in situ with full intelli-sense support and not need to have to manually copy the library files from a development folder to the Arduino libraries folder every time I make updates.

Thanks again for the help!

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


Posts: 12071
Location: United Kingdom
Joined: Apr 10th, 2010
Re: Workflow for creating a new Arduino Library?
Reply #3 - Apr 3rd, 2021 at 9:54pm
Print Post  
Excellent. Your solutions sound great. 

fyi: One point I didn't mention but of no consequence. Right click a shared library should show a Visual Micro "Publish" menu item. That copies a library back to the sketchbook/libraries folder.

  
Back to top
WWW  
IP Logged
 
Zenra
Junior Member
**
Offline


Posts: 29
Joined: Mar 8th, 2017
Re: Workflow for creating a new Arduino Library?
Reply #4 - Apr 8th, 2021 at 1:53am
Print Post  
Tim - I did not know that but am happy you shared the tip - will almost certainly use it under the right circumstances.
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint