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
Hot Topic (More than 8 Replies) Include SubFolder (Read 9292 times)
testato
Junior Member
**
Offline


Posts: 48
Joined: Feb 11th, 2014
Include SubFolder
Apr 26th, 2016 at 10:09am
Print Post  
from many version ago, the arduino IDE support the subfolder inside the sketch folder.
This is a very important improvement for Arduino, so you can put your personal .h/.cpp inside a subfolder of the sketch, or you can put your personal library directly inside sketch folder.

This is not supported in VisualMicro ?
I have the last 1604.18.0 on VS2015 and this kind of include do not work
Code
Select All
#include "SubfolderTest/lib_test.h"

fatal error: SubfolderTest/lib_test.h: No such file or directory 



Always thanks for your great product and support  Smiley

« Last Edit: Apr 26th, 2016 at 10:24am by testato »  
Back to top
 
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12188
Location: United Kingdom
Joined: Apr 10th, 2010
Re: Include SubFolder
Reply #1 - Apr 27th, 2016 at 3:51am
Print Post  
I will look into it thanks. Can you provide a zip of a simple project that uses this structure, one that compiles in the arduino ide?

Thanks
  
Back to top
IP Logged
 
testato
Junior Member
**
Offline


Posts: 48
Joined: Feb 11th, 2014
Re: Include SubFolder
Reply #2 - Apr 29th, 2016 at 2:41pm
Print Post  
Yes,
the attached example work on Arduino IDE and not on VisualMicro.

Many people always use subfolder inside sketchfolder, so this is a real important update for VisualMicro
  

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


Posts: 12188
Location: United Kingdom
Joined: Apr 10th, 2010
Re: Include SubFolder
Reply #3 - Apr 29th, 2016 at 2:48pm
Print Post  
Sub folders with source code should be working. I think the sketch source path is missing from the compiler statement so the relative paths can't be resolved. I will look into it.

I was confused when you said "your personal library directly inside sketch folder" which i thought you were saying should allow arduino libraries below a sketch. 

Do you agree that you are simply referring to your own .h files in sub folders and not .cpp files or arduino libraries?
  
Back to top
IP Logged
 
testato
Junior Member
**
Offline


Posts: 48
Joined: Feb 11th, 2014
Re: Include SubFolder
Reply #4 - Apr 29th, 2016 at 3:12pm
Print Post  
also .cpp and library, this is the real improvement

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


Posts: 12188
Location: United Kingdom
Joined: Apr 10th, 2010
Re: Include SubFolder
Reply #5 - Apr 29th, 2016 at 3:32pm
Print Post  
I don't see how you can place libraries under the folder. 

Are then simply compiled as normal project source code and not as library code?

I added a .cpp with invalid code to a sub folder with a test.h. In the .ino I #included the .h.

The sketch compiled without error which suggests it found the .h but did not compile the .cpp
« Last Edit: Apr 29th, 2016 at 3:33pm by Tim@Visual Micro »  
Back to top
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12188
Location: United Kingdom
Joined: Apr 10th, 2010
Re: Include SubFolder
Reply #6 - Apr 29th, 2016 at 3:46pm
Print Post  
I have looked at this again and Visual Micro does support headers in sub folders but you need to include them in the project. 

The full/paid version of visual micro also supports cpp code in sub folders and also supports libraries in a special sub folder name. I haven't seen anything in the arduino ide that supports these so a project with a library and also with .cpp code in a sub folder that works in arduino will be useful thanks.

You can see in the attached picture how to include code in your projects. Please try it and let me know if it makes sense. I will consider if Visual Micro should automatically include header files in the build without need to include them in the project.


« Last Edit: Apr 29th, 2016 at 3:47pm by Tim@Visual Micro »  

Please Register or Login to the Forum to see File Attachments
Back to top
IP Logged
 
testato
Junior Member
**
Offline


Posts: 48
Joined: Feb 11th, 2014
Re: Include SubFolder
Reply #7 - Apr 29th, 2016 at 4:54pm
Print Post  
Look at the attached examples. It work under Arduino IDE
  

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


Posts: 12188
Location: United Kingdom
Joined: Apr 10th, 2010
Re: Include SubFolder
Reply #8 - Apr 29th, 2016 at 6:23pm
Print Post  
Thanks I don't know why my first test with arduino failed.

I have looked into this and Arduino has discovered files in sub folders since the latter part of last year when the new "deep search auto resolve" was introduced to the build processes. The feature was initially introduced for library-in-library discovery but has been extended to local project files and sub folders.

Visual Micro is not automatically looking in the project sub folders and will be extended to do that.

However as per my previous message Visual Micro does allow for this. Did you try my earlier suggestion? Did you notice the "Show all files" option on the solution explorer. You can highlight all files or folders (use CTRL key for multiple) then right click "Include in project"

You can see in the image below that I have included the files in the project. It then compiled correctly.

I still can't see a way for the Arduino Ide to determine a library which would be #include without the sub folder name. ie: #include "myLib.h". Were you suggesting that Arduino Libraries should work or just talking about local project code in sub folders?

  

Please Register or Login to the Forum to see File Attachments
Back to top
IP Logged
 
testato
Junior Member
**
Offline


Posts: 48
Joined: Feb 11th, 2014
Re: Include SubFolder
Reply #9 - Apr 30th, 2016 at 12:38am
Print Post  
Tim@Visual Micro wrote on Apr 29th, 2016 at 6:23pm:

Visual Micro is not automatically looking in the project sub folders and will be extended to do that.

thanks, this will be an important news for visualmicro

Quote:

Did you try my earlier suggestion?  "Include in project"

Yes it work, but the automatic inclusion will be simple  Wink


Quote:

I still can't see a way for the Arduino Ide to determine a library which would be #include without the sub folder name. 

I mean a library whitin a subfolder.
Example: i have a library named Pippo in the Arduino standard library position, I remove it from standard position and insert it under the Sketch folder.
So i will use it by #include "Pippo/Pippo.h"

You are writed of a special directory that we can also use for the personal library, whitch one ? I never used it
  
Back to top
 
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12188
Location: United Kingdom
Joined: Apr 10th, 2010
Re: Include SubFolder
Reply #10 - Apr 30th, 2016 at 12:48am
Print Post  
That's just the same as the more.cpp isn't it. Just manually adding the lib sources to the project and then include same way as Arduino ide?

Doesn't that work?
  
Back to top
IP Logged
 
testato
Junior Member
**
Offline


Posts: 48
Joined: Feb 11th, 2014
Re: Include SubFolder
Reply #11 - Apr 30th, 2016 at 9:43am
Print Post  
yes, the manually adding of a library, or of a personal .cpp code, work in the same way by adding the SubFolder to the project via VisualStudio "Add to Poject".

So if you add Automatic Inclusion of the SubFolder, like in arduino IDE, the solution will work for library inside a subfolder and for personal code inside subfolder.

This is what i mean from the beginning  Smiley
I think it is important that a project that Build on Arduino IDE, will automatically work also in VisualMicro, whitout manually doing nothing
I Attached a project whit a real Library inside for your testing
« Last Edit: Apr 30th, 2016 at 9:48am by testato »  

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


Posts: 12188
Location: United Kingdom
Joined: Apr 10th, 2010
Re: Include SubFolder
Reply #12 - Apr 30th, 2016 at 12:12pm
Print Post  
Thanks. Yes I agree although I will give it some thought.

A small note also to say that you can not do that with some libraries because libraries are normally compiled separate to the project code for important reasons. So if some libs fail to compile as project code you should know why Smiley

I will think about the auto discovery of local code. Certainly the first time an existing arduino project is opened the code in folders below the project should be automatically included in the solution explorer.

After that I think we need a menu option. Experienced Visual Studio users will find it confusing but Arduino users will expect it  Undecided

To answer the question I thought were asking...

With the full/paid version of visual micro you can click "vMicro>Add Code>Add new arduino library". This will show you how to include an Arduino library below the sketch code but still allow the library to be #included and compiled as a genuine Arduino library. 

Library #includes do not have any path in the name so it will be #include "myLib.h" not include "src/_micro-api/libraries/myLib/myLib.h"

Thanks again
« Last Edit: Apr 30th, 2016 at 12:16pm by Tim@Visual Micro »  
Back to top
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint