Welcome, Guest. Please Login or Register
Arduino IDE for Visual Studio
 
  HomeSearch Tutorials & Wiki visualmicro.com LoginHelpRegister  
 
Page Index Toggle Pages: 1
Send Topic Print
Adding Board Hardware Libraries into the Visual Studio Solution (Read 54 times)
Visual Micro
Administrator
*****
Offline



Posts: 7979
United Kingdom
Re: Adding Board Hardware Libraries into the Visual Studio Solution
Reply #2 - Sep 13th, 2017 at 2:55am
 
I've switched your email notifications on when posts are made on your threads.
Back to top
 
WWW  
IP Logged
 
Visual Micro
Administrator
*****
Offline



Posts: 7979
United Kingdom
Re: Adding Board Hardware Libraries into the Visual Studio Solution
Reply #1 - Sep 13th, 2017 at 2:52am
 
I wouldn't recommend put core and libs in a project although you can effectively do the same thing.

There are 3 distinct phases to an arduino compile. 1) Core 2) Libraries 3) Project. Core is created to be clean and have no connection to the other code. In fact it is built and then compressed into an an archive (core.a) then passed to the linker as the single file.

Libraries are compiled individually, can reference the core but do not normally have access to project code.

The project has access to all.

To edit or clone your own versions of libraries is very easy using shared projects. To see how a library shared project works add any library to a project using the visual micro "add library" menu. Notice the menu also has a checkbox that says "Create a project when adding libraries". Make sure the menu is checked then add a library.

Normally adding an arduino library is just a matter of adding an #include to the code but with the "create a project" option enabled Visual Micro will create a shared project and add it to the current solution along with a readme file explaining how to add a reference to the new shared lib project to any normal Arduino project.

...

It's easy and after you add a Reference intellisense and build will be more flexible.

The next test would be to remove the Reference and remove the lib from the solution. Then with windows explorer copy the library folder to any location on your pc. The back in VS click "File>Add existing project" and select your library project from its new location. Then add a Reference from the Arduino project to the shared lib project.

You will soon discover that a VS shared project is a simple project_name.vcxitems file. The file is a special Visual Studio project that can not be built directly and that inherits intellisense from the Startup Project of the current solution.

For Visual Micro a shared Arduino library project is simply a standard VS shared c++ items project located in a folder that has an arduino library.properties text file. During build, Visual Micro will detect the project References and use the source code from the shared project instead of from the original library.

By having your own library sources in shared projects you will find them easier to structure in the solution explorer.

I hope this makes sense. Some docs here

...

File>New>Project>Visual C++>Visual Micro>Arduino Library

You can also create a new library from scratch to experiment but don't forget to "Add a Reference" from the Arduino project to the Shared Project. This is especially important if the library is located outside of the official arduino storage areas.


Back to top
« Last Edit: Sep 13th, 2017 at 2:54am by Visual Micro »  
WWW  
IP Logged
 
SeattleArduino
Newbies
*
Offline



Posts: 1
Adding Board Hardware Libraries into the Visual Studio Solution
Sep 13th, 2017 at 2:26am
 
Can I included the entire hardware repository in the project and compile using that on a per project basis?  I am using the ESP8266 Code base
(esp8266/hardware/esp8266/2.3.0/libraries/ESP8266WiFi )
- https://github.com/esp8266/Arduino

The issue is I need to make modifications to this repository for specific project and would like to use github.com to keep track of my code base changes.

Thank you!


Back to top
 
 
IP Logged
 
Page Index Toggle Pages: 1
Send Topic Print