Welcome, Guest. Please Login or Register
Arduino IDE for Visual Studio
 
 
When Logging a Support Issue in the Forum, please ensure you have also:-
  • Enabled vMicro > Compiler > Show Build Properties and Verbose
  • Re-Compile your program with these settings enabled
 
Save the new Output to a Text File and....
Support requests without the output above may be impossible to answer, so please help us to help you
 
  HomeSearch Tutorials & Wiki visualmicro.com LoginHelpRegister  
 
Page Index Toggle Pages: 1
Send Topic Print
Library Development (Read 71 times)
Victor Leung
Newbies
*
Offline



Posts: 1
Library Development
Sep 15th, 2019 at 12:15pm
 
Hi all,

I'm trying to develop an Arduino Library and I'm having trouble understanding the "Reference" concept and the "Create shared Project" option.

I created a very simple test case:

1. I create a new Arduino Library Project using the VS "new project" dialog. It is named `reliable_messenger`. Lets say the folder is located under "C:\GitHub\ArduinoDev\library\"

I also set the "Optional Sketch Book Location" to the root folder of this library (say:  "C:\GitHub\ArduinoDev\") . So VisualMicro can discover this library.

2. In the Solution Explorer: I create a new Arduino Project named `Echo`. This is placed in a new `examples` folder of the library.

3. With the new Echo.ino opened, I click on the "Add Library" button and I select `reliable_messenger`. The option "Create Shared Project when Including Libraries" is not selected. A new line is automatically added :

#include <reliable_messenger.h>

4. I am able to compile Echo.ino. This is good. But when I want to start programming the library: reliable_messenger.h and reliable_messenger.cpp I do not get any IntelliSense or Arduino reference.

5. I follow the tutorial https://www.visualmicro.com/page/User-Guide.aspx?doc=Add-Libraries.html and performed the following:

6. I navigated in the Solution Explorer, under the project Echo, Under Reference, I right clicked and selected the `reliable_messenger` project as reference.

7. Now IntelliSense is working in reliable_messenger.h but the project Echo.ino will not compile.

Code:
Compiling 'Echo' for 'Arduino/Genuino Uno'
Build Folder: "file:///C:/Users/leungp/AppData/Local/Temp/VMBuilds/Echo/uno/Debug"
   Object reference not set to an instance of an object



	An error was encountered during the 'Deep Search' library discovery process.
Build failed for project 'Echo'
 



Back to top
 
 
IP Logged
 
Visual Micro
Administrator
*****
Offline



Posts: 10463
United Kingdom
Re: Library Development
Reply #1 - Sep 15th, 2019 at 6:17pm
 
There are a few things here but please always follow the yellow guide at the top of the page to show your config more clearly.

The arduino sketch book folder is often best left blank and only changed when it is understood fully. The sketchbook folder is where arduino stores projects and also expects to find user installed libraries below a sub folder called "Libraries".

If you place or create new librarues in the sketchbook\libraries then you should click the rescan button on the vmicro menus (or platform explorer). restarting the ide also re-reads the config.

When using libraries from the sketchbook\libraries folder adding an #include should be all that is required for both intellisense and build to work. If intellisense fails but build works it's possible you have a one off glitch so try restarting the ide.

The above discusses standard arduino.

Additionally in visual micro a library can exist anywhere although you should avoid putting them below the project.

Regardless of where a library is located you can use the refrences to add the library as a "shared project" not just a standard project reference. You can see the shared project tab on the left side of the add reference dialog.

Your library does need to exist as a shared c++ project in the solution and then it should appear as a shared project reference for the main arduino project.

The vMicro add>library menu provides some simple workflows that will add a library to the solution explorer if it doesn't already exist, create a shared project and add the shared project reference to the current project.

I suggest you ignore shared projects to start with. Just add a simple arduino library which gives you the #include. Ensure intellisense and uild are working before moving on to shared projects. If not then follow the guide in yellow.

Thanks

Back to top
 
WWW  
IP Logged
 
Page Index Toggle Pages: 1
Send Topic Print