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 Sharing Arduino code between projects (Read 1417 times)
Flint
Newbies
*
Offline


Posts: 4
Joined: Apr 29th, 2020
Sharing Arduino code between projects
May 13th, 2020 at 3:40pm
Print Post  
Hello.
in post https://www.visualmicro.com/post/2016/05/27/Sharing-code-between-projects.aspx
you wrote: "NOTE: Click the "Add as link" option when adding the code"
where i can find this option?
  
Back to top
 
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12071
Location: United Kingdom
Joined: Apr 10th, 2010
Re: Sharing Arduino code between projects
Reply #1 - May 13th, 2020 at 4:14pm
Print Post  
Thanks for the post. The article has been updated.

Quote:
In more recent IDE's such as Vs2017/2019 use "Add Existing Item" which automatically creates the link to the source.

Tip: After you add files, click the file and press F4 to see if a file is local to the project or shared.
  
Back to top
WWW  
IP Logged
 
Flint
Newbies
*
Offline


Posts: 4
Joined: Apr 29th, 2020
Re: Sharing Arduino code between projects
Reply #2 - May 13th, 2020 at 4:42pm
Print Post  
yes i use VS2019.
i have one more question:
after add file to second project i  include .h file in this project .ino file, but take compiller error: "Test2.ino: 7:10: fatal error: ./../Test1/src/TestClass/MyTest.h: No such file or directory
   #include "./../Test1/src/TestClass/MyTest.h""
i attach test solution.
thank you
  

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


Posts: 12071
Location: United Kingdom
Joined: Apr 10th, 2010
Re: Sharing Arduino code between projects
Reply #3 - May 13th, 2020 at 4:45pm
Print Post  
Use shared projects for cpp/h code. Use add existing for .ino code.

Documentation Available Here
« Last Edit: May 13th, 2020 at 4:50pm by Simon@Visual Micro »  
Back to top
WWW  
IP Logged
 
Flint
Newbies
*
Offline


Posts: 4
Joined: Apr 29th, 2020
Re: Sharing Arduino code between projects
Reply #4 - May 13th, 2020 at 5:04pm
Print Post  
it's not a Shares Code Project. both are standart "Ardino project" like in you document https://www.visualmicro.com/post/2016/05/27/Sharing-code-between-projects.aspx you add .cpp and .h file not .ino
I try use sared code project, but i can't add library to this project type
  
Back to top
 
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12071
Location: United Kingdom
Joined: Apr 10th, 2010
Re: Sharing Arduino code between projects
Reply #5 - May 13th, 2020 at 6:09pm
Print Post  
You can add #includes for libraries to shared projects and they will be discovered. If you don't know which includes to add then add the library to your .ino and then grab the #includes. You can remove the #included from the .ino after that but they will not do any harm.

If you need more help it is important to show the code you have used to add #includes to your add existing > shared code.
  
Back to top
WWW  
IP Logged
 
Flint
Newbies
*
Offline


Posts: 4
Joined: Apr 29th, 2020
Re: Sharing Arduino code between projects
Reply #6 - May 14th, 2020 at 5:14am
Print Post  
Thank you.
so, as i understand i can't include .h files from from location that not in references project?
for example i can't create "c:\Common Include" folder for h files that commons for all my projects?
  
Back to top
 
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12071
Location: United Kingdom
Joined: Apr 10th, 2010
Re: Sharing Arduino code between projects
Reply #7 - May 14th, 2020 at 11:58am
Print Post  
Yes that is best, but also on the vMicro>Compiler menu you can enable the project folder -I include. This would then mean that the project folder is a compiler include path and .h files can be referenced as relative paths from that point...

For example:-

Project with include path = c:\foo\bar\MySketchProject

Allows for "..\SomeBarFolder\MyHeaders\Header1.h"
Allows for "..\..\SomeCFolder\MyHeaders\Header1.h"


Using the include path applies only to headers (.h). Files that need to be compiled to object files such as .cpp must be in shared project or the project.
  
Back to top
WWW  
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint