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 Creating new Arduino Libraries in VS2015 (Read 7146 times)
bart
Newbies
*
Offline


Posts: 4
Joined: Dec 29th, 2015
Creating new Arduino Libraries in VS2015
Jan 4th, 2017 at 7:35pm
Print Post  
I'm not sure where to start but here goes. Visual Micro is way better than arduino default IDE, but.....

I'm used to developing in c# using visual studio. I create a solution and split the code over several projects. Typically one for the main program and several library projects to separate any reusable code. Though Arduino toolset works different (libraries are uncompiled source files in a folder structure) I expected visual micro to still offer me a similar experience. 

So I create a solution using the "Arduino Project" template. Then I added another project using the "Arduino Library" template. I added the .cpp an .h files to the library project. Tried removing the unneeded ino file, but that broke the arduino library project. Got the library project to build. And then I expected to either be able to "add a reference" to the library in my main (startup) arduino project or to find that the content from the library project had been published/copied to the arduino libraries folder in the sketches folder so I could do rescan and add user library in the main project. However I cannot find such functionality. I seem to be required to go into windows explorer, find the library files and copy them to the libraries folder by hand. Not really a great experience when debugging and making frequent changes. This should really be a standard build action, but maybe I am missing something...

I did try to use the create local library function and that does work, but again no way to "publish" the library to the proper folders for the arduino ide.

I read something about using c++ linked/shared files project, but found that utterly confusing. 
I also found several pages about adding a user library to the project, but nothing whatsoever, no tutorial or example, about the proper way to go about actually making a user library the visual micro/arduino way.

To add to my confusion. The intellisense/code completion does pick-up the functions from the library project in the main project, but can't seem to find the source files when compiling....

Hopefully someone here can point my nose in the proper direction?
  
Back to top
 
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12191
Location: United Kingdom
Joined: Apr 10th, 2010
Re: Creating new Arduino Libraries in VS2015
Reply #1 - Jan 4th, 2017 at 8:17pm
Print Post  
Hi,

There are some planned improvements to make arduino library creation/publish easier. 

The structure of an arduino library is shown when you use the create local project library command. Visual micro creates the correct library structure so you can use windows explorer to copy/deploy a library for sharing. I accept that if you want to share and edit a library at the same time then this method isn't the best solution. However it allows a library to be debugged.

Using the format of an Arduino library means you can #include "libheader.h" without having to specify a folder location.

Creating a new arduino project as a library will not work. Visual micro expects and arduino project to be an arduino project and not just a normal c++ project which is what a library would be.

The shared project system is the easiest way to break code down into chunks. What did you find complicated about it? If you create a visual studio shared project and add a file called "mycode.h" then you can simply #include "mycode.h" in any arduino project that has a Reference to the shared project.

The plan is to provide a property on the shared projects that allows you to switch between "Compile as sketch code" and "Compile as library". This would then make creating a shared library in any location available to any project.

Probably a food idea to bear in mind that a library doesn't have a setup or loop (main) etc. so would not built in isolation.

I don't know if you have used "vMicro>toggle hidden files". This will allow you to see/edit library sources from the normal arduino library lications.

The idea is to stay as close to arduino as possible while opening up more and more additional options for users. If we stray too far then we end up having to support peoples code and people learning new ways of working,  which would be too time consuming and expensive for a mainly free product. That's where a make file would be better
« Last Edit: Jan 4th, 2017 at 8:20pm by Tim@Visual Micro »  
Back to top
IP Logged
 
bart
Newbies
*
Offline


Posts: 4
Joined: Dec 29th, 2015
Re: Creating new Arduino Libraries in VS2015
Reply #2 - Jan 5th, 2017 at 9:29am
Print Post  
I think your quite right to stay close to the original arduino tool-set and setup. But then what is the circled project template for in the new project dialog I circled in the attached picture? Or is that just meant as a simple start project already including a local library?

A shared c project would have me create the proper (but simple) file structure myself. It would certainly have no way to publish (or zip up) a library to the arduino user libraries folder.

I see that the local library is a pro/payed feature. Personally one of the main reasons for moving arduino to VS2015 is having a proper IDE with solution explorer and dock-able windows and one main windows in stead of one for every file or example you open... "Proper/complete" library publishing support is a pro feature I would happily give money for, even more so than the debugger.
  

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


Posts: 12191
Location: United Kingdom
Joined: Apr 10th, 2010
Re: Creating new Arduino Libraries in VS2015
Reply #3 - Jan 5th, 2017 at 12:14pm
Print Post  
Okay here are some answers

1)
The create library option gives you a normal sketch with one example local library below it. It's an example to get users up and running.

2)
There is a heck of a lot in the free version of visual micro and it takes a considerable amount of time to produce and support. The question is not if more functionality should be available for users but if existing functionality should no longer be free.


There is no doubt that via user feedback the product will continue to expand. 

Considering that no other products have half of what is in visual micro and that so much is free, it is disappointing that people do not feel they can appreciate what is there and contribute to help it grow.
  
Back to top
IP Logged
 
bart
Newbies
*
Offline


Posts: 4
Joined: Dec 29th, 2015
Re: Creating new Arduino Libraries in VS2015
Reply #4 - Jan 5th, 2017 at 3:25pm
Print Post  
Tim@Visual Micro wrote on Jan 5th, 2017 at 12:14pm:

1)
The create library option gives you a normal sketch with one example local library below it. It's an example to get users up and running.



Ok, I can understand this. I expected this to be the equivalent of the .net class library project. Thanks for clearing that up.

Tim@Visual Micro wrote on Jan 5th, 2017 at 12:14pm:
Okay here are some answers
2)
There is a heck of a lot in the free version of visual micro and it takes a considerable amount of time to produce and support. The question is not if more functionality should be available for users but if existing functionality should no longer be free.


There is no doubt that via user feedback the product will continue to expand. 

Considering that no other products have half of what is in visual micro and that so much is free, it is disappointing that people do not feel they can appreciate what is there and contribute to help it grow.


This makes me feel I have offended you, which was not intended. You are completely right that users get a lot of functionality for free (which I do appreciate) and I do not think I ever claimed otherwise. I only meant to convey that I personally would find enhancements for library development more important than the debugger which seems to be your main pro selling point. I might be alone in this, but it's just meant as my feedback. I'm still in my trail period, but I already decided I need to buy a license because I want to keep local library support, to me the debugger is just icing on the cake. Realize that English is not my first language, I hope I have explained myself better this time. 
  
Back to top
 
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12191
Location: United Kingdom
Joined: Apr 10th, 2010
Re: Creating new Arduino Libraries in VS2015
Reply #5 - Jan 5th, 2017 at 4:20pm
Print Post  
Hi,

I am really sorry I made you feel like that. Not the intention at all and your post helps towards deciding on priorities.

It's a very good topic to discuss how it can be implemented. The product has to cater for many types of users. Some experienced with C# and new to micro-controllers, some with C++ and new to arduino, some new to all code and some experienced in all areas.

The main goal that allows support to remain at a minimum and keep the product free or at very low price. Unfortunately it's very difficult for new arduino users to know what is standard arduino and what is "extra" tools provided by visual micro. 

It gets very confusing if users believe some extra feature is standard arduino and then attempt to seek assistance in, for example, the arduino forum.

You will be amazed at how confused users can become. You might ask that you could edit all libraries more obviously in the software and then to edit the core of the board which is also located in a different location. Reasonable requests but many new users would think this is normal for arduino, edit libs and core, then wonder why other projects have broken.

Arduino libraries are very simple so using windows explorer isn't a huge difference from having a publish facility yet it would require an auto backup/versioning consideration that would be quite time consuming to design when there are so many other more useful features that could be created in the same time frame.

During the past 18 months arduino has made huge changes, for the better, to the build process. It has only recently established hence the last release focused on build times/cache.

Hopefully we can now get back to more fun things such as managing project properties in a way that more easily allows teams to share via source control and making editing or creating of libraries and new cores easier.

The shared projects are an interesting route. Currently the code from shared projects is simply merged with project code. This is useful for some users because that means the shared code can interact with the project code, where as arduino libraries have no connection to the project code.

The reason why I say shared projects are interesting is because the plan for next release is to provide a property on each shared project that allows you to specify if the code should be compiled as project code or as a library. This will give editable libraries from any location n a pc.

As a windows developer you are used to references to windows .dll files etc. The closes thing to that for the gcc c++ language is .o and .a files however they are supported by arduino as files you can "include" in a project and would also not work well for intellisense purposes.

Hope this makes sense, we really recommend using the arduino ide for a short time to understand what arduino is so you can more easily see where we are and suggest where to go next 

  
Back to top
IP Logged
 
bart
Newbies
*
Offline


Posts: 4
Joined: Dec 29th, 2015
Re: Creating new Arduino Libraries in VS2015
Reply #6 - Jan 8th, 2017 at 5:55pm
Print Post  

I already spent time with the arduino IDE and for someone used to Visual Studio it is a severe letdown. Barely better than notepad. That's why I am happy Visual Micro exists. Giving me a proper development environment.

As a developer myself I do appreciate the difficulties in dealing with the requirements of customers with different backgrounds. There is always someone unhappy with your choices.

For now I took my wish as an excuse to create a visual studio extension myself, adding the commands I thought missing. I have never done this before and it took me a few hours to create even the basic extension that I wanted. The extension creates two new commands on the project node for visual micro arduino projects:

* Publish libraries:
Copies all local libraries in the project to the libraries folder in the sketches folder. This allows both the arduino library manager and VM arduino library manager to "see" them. I can develop the library in a single project than push publish and all my other projects would can just treat it as any other arduino library.
* Package Libraries:
Basically the same as publish but it zips them to the project output folder. Again the zip is acceptable to the arduino library manager and I could send it to any arduino user...

I must say that making the extension was made considerably easier because of you sticking to the proper arduino file structure for libraries in the projects. I do not intend to publish it as I have no time to properly test and maintain it and local libraries requires a pro version, something not everybody has. I would also need to fix the fact that after adding a local library to a project the library.properties files is not included (but can be by doing show hidden files an including it). But it works for me and is the clearest example of what I found was missing for my use. 

I have included the code in a zip file to look at, but there is nothing special in there.... The solutions does assume you have the extensiontools extension installed, but I take that as a given for you and it should build without.


  

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


Posts: 12191
Location: United Kingdom
Joined: Apr 10th, 2010
Re: Creating new Arduino Libraries in VS2015
Reply #7 - Jan 8th, 2017 at 6:26pm
Print Post  
That's really excellent and useful. Thanks very much!

...

Some things that might help sometimes....

I forgot to mention the "vMicro>Toggle Hidden Files". 

If there is a src\_micro-api then any #included libraries are automatically copied and created as local project libraries

If there is not a src\_micro-api then all the core and #included library sources are automatically created as short cuts under a filter called src\_micro-api-readonly

If "toggle hidden files" is in "short cut mode" the core and the library sources are automatically switched when a different board is selected. 

The core and library code short cuts that appear under the "src\_micro-api-readonly" folder continue to be compiled as normal. Therefore they can be altered but will affect all projects and cause longer compile times because changing core causes a recompile.

Thanks again

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