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 Library files not found when creating a new library (Read 1965 times)
Chevelle
Junior Member
**
Offline


Posts: 29
Joined: Feb 29th, 2020
Library files not found when creating a new library
Feb 29th, 2020 at 1:32pm
Print Post  
I am a long time user of VS and almost as long time user of VM.  I have installed VS2019 and the latest version of VM.  Although I have done many VM projects, I am working on my first library and I haven't gotten out of the gate very far.

I selected the Arduino Library option to start the effort and the standard templates for .cpp and .h were set up.  The problem is that any #include files are not being recognized.  For example, the arduino.h and SPI.h libraries are not recognized.  The Arduino IDE is installed fine and recognized by VM.

I expect it is something simple but oddly, when projects that use these libraries, they are recognized just fine. As a test, I copied in known good .h and .cpp files in to the header and source tree and the included libraries were not recognized.  However, when I load them in but not under the header or source folders, the includes show as recognized.

Thanks in advance for your help.
  
Back to top
 
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12186
Location: United Kingdom
Joined: Apr 10th, 2010
Re: Library files not found when creating a new library
Reply #1 - Feb 29th, 2020 at 2:09pm
Print Post  
Hi

I think you have missed adding the shared include from your arduino project to your library project.

Right click the "References" node below your project in the solution explorer or right click the project and select "Add Reference". When that window opens there is a tab on the left for "Shared Projects". Your project will be in the list, ensure it is selected/checked, then click OK
  
Back to top
IP Logged
 
Chevelle
Junior Member
**
Offline


Posts: 29
Joined: Feb 29th, 2020
Re: Library files not found when creating a new library
Reply #2 - Feb 29th, 2020 at 2:27pm
Print Post  
It isn't the inability to recognize included libraries in a project.  It is the inability to recognize included libraries within a library.

I am writing a library to support a stepper motor controller IC.  Right off the bat when I created a "Arduino Library Project", starting .h and .cpp files were created.  The template added the lines to check for and include either Arduino.h or WProgram.h.  Neither of these is recognized.

Yet if I remove them from the header and source folders and just have them under the project, these libraries are recognized.

Also, I guess within a library project, there isn't the option to add references.

Very odd.  I guess I can always created these .h and .cpp files as projects, not libraries.
  
Back to top
 
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12186
Location: United Kingdom
Joined: Apr 10th, 2010
Re: Library files not found when creating a new library
Reply #3 - Feb 29th, 2020 at 2:37pm
Print Post  
Let me make some points about arduino libraries. Then let me know if the compiler doesn't find your libs in libs. It sounds like you have setup as per below but are reporting an issue only with Libs in Libs? Right? Anyway I will make these points to ensure we are on the same page.

An Arduino library is not a standalone program. To use a library you need a real arduino project in your solution.

Libraries used within libraries are automatically discovered when you click build and only if you have vMicro>Compiler>Deep search for libraries enabled, which it is by default. (We use the same system as the arduino ide which uses Gcc-E to discover #includes that can then be matched to libraries. If you do not use deep search then make sure you hve #includes for one header from each library in the .ino code.)

When working with editable shared libraries in the Ide, the intellisense is clever. The same library can be used by two different arduino projects, each arduino project can have a different board/mcu specified. The intellisense for shared libraries in the solution will dynamically change for the board/mcu of whichever Arduino project is the "Startup Project" (shown in bold). This is actually how the Microsoft shared c++ projects work and your library is nothing more than a shared c++ project at this stage.

« Last Edit: Feb 29th, 2020 at 2:50pm by Tim@Visual Micro »  
Back to top
IP Logged
 
Chevelle
Junior Member
**
Offline


Posts: 29
Joined: Feb 29th, 2020
Re: Library files not found when creating a new library
Reply #4 - Feb 29th, 2020 at 2:42pm
Print Post  
This is so bizarre.  Just for my sanity, I have opened a project in VS2019 and in another instance opened this library project.  In the project instance, I can add references, etc. and the option to deep search for libraries is there.  However, in the library project, neither of those options is present.
  
Back to top
 
IP Logged
 
Chevelle
Junior Member
**
Offline


Posts: 29
Joined: Feb 29th, 2020
Re: Library files not found when creating a new library
Reply #5 - Feb 29th, 2020 at 2:46pm
Print Post  
Oh, I fully appreciate the difference between libraries and projects.  Maybe that is my problem.   Wink

For the record, I am trying to create a library that simplifies the use of a specific IC (L6470).  To be used, this library must be included in the user's project, i.e. a library cannot be uploaded and executed as a standalone project.
  
Back to top
 
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12186
Location: United Kingdom
Joined: Apr 10th, 2010
Re: Library files not found when creating a new library
Reply #6 - Feb 29th, 2020 at 2:49pm
Print Post  
That's right. It's good work to rationalize code in libraries but you do need a real project to test with. A library is not a program in its own right, just code. Only a full project can cause the library to run.
  
Back to top
IP Logged
 
Chevelle
Junior Member
**
Offline


Posts: 29
Joined: Feb 29th, 2020
Re: Library files not found when creating a new library
Reply #7 - Feb 29th, 2020 at 2:50pm
Print Post  
Understood.
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint