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) Compile error with #include "../Shared/CommsProto.h" (Read 5620 times)
vmsh
Junior Member
**
Offline


Posts: 16
Joined: Jul 9th, 2017
Compile error with #include "../Shared/CommsProto.h"
Jul 10th, 2017 at 11:40am
Print Post  
I thought the syntax difference only changed the search priority between the different include paths, is this behaviour standard?
« Last Edit: Jul 11th, 2017 at 8:27pm by Tim@Visual Micro »  
Back to top
 
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12076
Location: United Kingdom
Joined: Apr 10th, 2010
Re: Unable to access header files
Reply #1 - Jul 10th, 2017 at 12:11pm
Print Post  
Yes std c++ visual micro can't affect it unless it adds the project folder as compiler -I include path, that would give project  root <bar.h> and relative paths below project root <foo/bar.h>.

However a header in a folder with a .cpp where both are in a project sub folder might still be an issue, <bar.h> still wouldn't work in that case you would need <foo/bar.h> even if bar.cpp was in same folder as bar.h.

So it's clearer as it stands but more stringent. I think it's going to become an option Smiley
  
Back to top
WWW  
IP Logged
 
vmsh
Junior Member
**
Offline


Posts: 16
Joined: Jul 9th, 2017
Re: Unable to access header files
Reply #2 - Jul 11th, 2017 at 11:04am
Print Post  
Thank you.
A new problem has arisen. I since moved some of the header files in a higher level "Shared" folder. I'm referring to these headers with the following syntax:

Code (C++)
Select All
#include "../Shared/CommsProto.h" 



The relative paths are correct, I'm 100% sure. The #include line doesn't get underlined, so IntelliSense should be in agreement with me. Furthermore, when typing in the paths, IntelliSense actually autocompleted the header filenames for me.
However, when I compile I get errors such as:

EmperorToolkitMega2560.ino: 8:34: fatal error: ../Shared/CommsProto.h: No such file or directory
   #include "../Shared/CommsProto.h"
   compilation terminated



     An error was encountered during the 'Deep Search' library discovery process.


Doing the same thing in a Win32 project in the same solution works just fine.
« Last Edit: Jul 11th, 2017 at 11:05am by vmsh »  
Back to top
 
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12076
Location: United Kingdom
Joined: Apr 10th, 2010
Re: Unable to access header files
Reply #3 - Jul 11th, 2017 at 3:02pm
Print Post  
does it work if you uncheck vmicro>compiler>deep search?
  
Back to top
WWW  
IP Logged
 
vmsh
Junior Member
**
Offline


Posts: 16
Joined: Jul 9th, 2017
Re: Unable to access header files
Reply #4 - Jul 11th, 2017 at 6:50pm
Print Post  
It does not. Same error, without the "deep search" part.
  
Back to top
 
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12076
Location: United Kingdom
Joined: Apr 10th, 2010
Re: Compile error with #include "../Shared/CommsProto.h"
Reply #5 - Jul 11th, 2017 at 8:28pm
Print Post  
Header files includes are case sensitive so make sure the case is correct.

This is a syntax or location error.

Please give a simple overview of where your files exist in windows explorer.

Thanks
  
Back to top
WWW  
IP Logged
 
vmsh
Junior Member
**
Offline


Posts: 16
Joined: Jul 9th, 2017
Re: Compile error with #include "../Shared/CommsProto.h"
Reply #6 - Jul 11th, 2017 at 8:41pm
Print Post  
Thank you for your ongoing assistance.

I've attached an image representing the files tree. The include statements have since been changed to:

#include "../Shared/CommsProto_Board.h"

I've marked in green all the source file that reference the problematic header file. The case seems to be correct. I feel like I'm missing something obvious.

The whole error string is:

Compiling debug version of 'EmperorToolkitMega2560' for 'Arduino/Genuino Mega w/ ATmega2560 (Mega 2560)'
 
EmperorToolkitMega2560.ino: 8:40: fatal error: ..\Shared\CommsProto_Board.h: No such file or directory
   #include "..\Shared\CommsProto_Board.h"
   compilation terminated
 
Error compiling project sources
Comms.cpp:1: In file included from
Debug build failed for project 'EmperorToolkitMega2560'
 
Comms.h: 3:40: fatal error: ..\Shared\CommsProto_Board.h: No such file or directory
   #include "..\Shared\CommsProto_Board.h"
   compilation terminated


I noticed that it doesn't reference all the source files I've marked. I don't know whether that means something or it is expected.
  

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


Posts: 12076
Location: United Kingdom
Joined: Apr 10th, 2010
Re: Compile error with #include "../Shared/CommsProto.h"
Reply #7 - Jul 11th, 2017 at 9:08pm
Print Post  
In the arduino world there are .ino files. These files are combined into a standard cpp source during compile. For this to happen the build takes place in a temp build folder. 

Therefore the arduino world starts where your EmperorToolkitMega2560.ino and EmperorToolkitMega2560.vcxproj files are found.

You should consider folder outside of this directory structure to be excluded and non-valid.

The only way to have shared sources with normal arduino is to use a library which must be located in known locations.

Visual studio and visual micro do provide the ability to use shared sources from outside of the project tree but only under one of two clear sets of conditions. 

1) 

You would create a visual studio c++ shared project. Then add .cpp/h sources to it and use the References node below your arduino project to add a reference to the shared project. 

In this case visual micro will merge the sources (during compile) with the temp folder structure of the arduino project. Therefore a file in "SharedProject/Folder1/Header1.h" will be access from your .ino code as #include "Folder1/Header1"

or

2)  

You can create shared arduino library projects in a similar way using c++ shared projects. These projects must contain sources that follow the arduino library specification namely a library.properties text file in the root or each lib project.

Use the "create a project" on the visual micro "add library" menu to demonstrate how to create a library project. The option will create a project when you select a library to use in your code. You still need to use the "add reference" facility mentioned above so that intellisense and libs outside of std arduino locations can be discovered.

...

There is a final quick and dirty way. Add each of your shared sources to the as "links/shortcuts" using the vs "add existing item" menus. In this case visual micro will, during compile, copy sources to the root of the temp project folder. This means that regardless of where the sources are located your arduino code will reference them as if they are in the root of your arduino project.

...

There are some changes due out for the compiler which might help in the future but right now these are the best solutions.
« Last Edit: Jul 11th, 2017 at 9:13pm by Tim@Visual Micro »  
Back to top
WWW  
IP Logged
 
vmsh
Junior Member
**
Offline


Posts: 16
Joined: Jul 9th, 2017
Re: Compile error with #include "../Shared/CommsProto.h"
Reply #8 - Jul 11th, 2017 at 9:16pm
Print Post  
Ah, that explains it! Thank you for your assistance.

Update: solution 1 works wonderfully for both Arduino projects and Win32 projects.
« Last Edit: Jul 11th, 2017 at 9:25pm by vmsh »  
Back to top
 
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12076
Location: United Kingdom
Joined: Apr 10th, 2010
Re: Compile error with #include "../Shared/CommsProto.h"
Reply #9 - Jul 11th, 2017 at 9:27pm
Print Post  
Gosh, at last, someone who understands me  Smiley
  
Back to top
WWW  
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint