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 Shared library project with subfolder (Read 920 times)
DeeJay
Newbies
*
Offline


Posts: 3
Joined: Sep 6th, 2022
Shared library project with subfolder
Sep 6th, 2022 at 8:56am
Print Post  
Hi!

I have a Solution with a multiple Arduino Projects and multiple shared Arduino Library Projects. Basically what I did is similar to your tutorial video https://www.youtube.com/watch?v=7ObDIvHuMvc. In this (basic) setup projects are compiling without errors but if I move cpp/h files in Library Project from "\src" folder into sub folder "\src\SubFolder" I got error in Arduino Projects "cannot open source file...". I can resolve this error by changing include to

Code (C++)
Select All
#include <SubFolder/MyLibrary.h> 



but then I get error "Deep search for libraries... Object reference not set to an instance of an object" while compiling.

According to library readme.txt "Code should be in the src folder, code in sub folders below the \src folder are also supported." so this should work. What I'm doing wrong?
  
Back to top
 
IP Logged
 
Simon@Visual Micro
Administrator
*****
Offline


Posts: 2174
Joined: Feb 13th, 2019
Re: Shared library project with subfolder
Reply #1 - Sep 6th, 2022 at 9:01am
Print Post  
Can you confirm if you are moving the files using the Solution Explorer in Visual Studio, or just in Windows Explorer?
  
Back to top
 
IP Logged
 
DeeJay
Newbies
*
Offline


Posts: 3
Joined: Sep 6th, 2022
Re: Shared library project with subfolder
Reply #2 - Sep 6th, 2022 at 9:55am
Print Post  
I moved existing files in Solution Explorer. Also tried creating sub folder first and then creating new cpp/h files with add new item.
  
Back to top
 
IP Logged
 
Simon@Visual Micro
Administrator
*****
Offline


Posts: 2174
Joined: Feb 13th, 2019
Re: Shared library project with subfolder
Reply #3 - Sep 6th, 2022 at 10:25am
Print Post  
If you have the Library project "MyLibrary" then the src folder should contain the "MyLibrary.h" as a minimum.

Then for any other code to be included in the library these can be added to the e.g. src/SubFolders as needed, and referenced in the "MyLibrary.h" file.

The project could end up looking like below as an example:

MyLibrary\src\MyLibrary.h
MyLibrary\src\SubFolder\Formulae.h
MyLibrary\src\SubFolder\Formulae.cpp

So then in your sketch you would only need the include to the MyLibrary.h, which would bring in all other sources needed from the Library Project without specific includes needed in the sketch using it.
  
Back to top
 
IP Logged
 
DeeJay
Newbies
*
Offline


Posts: 3
Joined: Sep 6th, 2022
Re: Shared library project with subfolder
Reply #4 - Sep 6th, 2022 at 10:45am
Print Post  
Yes, that's it. Thanks!
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint