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 Path trouble developing arduino library (Read 3256 times)
JoeBloe
Newbies
*
Offline


Posts: 4
Joined: Jun 24th, 2018
Path trouble developing arduino library
Jun 24th, 2018 at 8:42pm
Print Post  
I am writing an Arduino library using VisualStudio 2017 Community Edition.  I have created 2 projects within the solution:
Project 1 contains my library code which I want to be in C:\blabla\development\arduino\"myLib"  (this makes it easiest for organizing many projects I develop).

Project 2 contains my .ino file which has the code that exercises the library.  Project 2 is the active project.  I want it in C:\blabla\development\arduino\"myLib" \myLibTest

For VS to find my library header file, my .ino file needs to #include<../MyLib.h> which makes sense given the layout.  However, VS cannot resolve the #include"arduino.h" in my library code.  The only way I can get it to do this is to put my library code into the Arduino Library folder and tell my .ino project to use that library.  Since I am mostly changing my library code, this means I have to continually copy the files from Project 1 to the library folder.

I tried pointing project 1 at the source in the library folder, but VS still can't find "arduino.h", but it can build and deploy to the chip just fine (i.e. VS can't resolve the include path but GCC can).

Is there a better way I should be using to configure my projects to develop an arduino library?

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


Posts: 12187
Location: United Kingdom
Joined: Apr 10th, 2010
Re: Path trouble developing arduino library
Reply #1 - Jun 25th, 2018 at 6:24pm
Print Post  
Are you clear about what an Arduino library is?
  
Back to top
IP Logged
 
JoeBloe
Newbies
*
Offline


Posts: 4
Joined: Jun 24th, 2018
Re: Path trouble developing arduino library
Reply #2 - Jun 25th, 2018 at 6:31pm
Print Post  
I suppose I could always be made better informed,
  
Back to top
 
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12187
Location: United Kingdom
Joined: Apr 10th, 2010
Re: Path trouble developing arduino library
Reply #3 - Jun 28th, 2018 at 6:43pm
Print Post  
Are you trying to create an arduino library or share some code from another project/location?

Your use of the word "library" might be confusing things for me.
« Last Edit: Jun 28th, 2018 at 6:44pm by Tim@Visual Micro »  
Back to top
IP Logged
 
JoeBloe
Newbies
*
Offline


Posts: 4
Joined: Jun 24th, 2018
Re: Path trouble developing arduino library
Reply #4 - Jun 28th, 2018 at 7:33pm
Print Post  
I am writing code that I will eventually make public for others to use as a library in their code.

During my development and testing I have a .ino file that I am using to exercise the code but I have kept it in a different Visual Studio project (in the same solution) because I won't be releasing that .ino file with the "library" .zip file since it is very unique to the way I have the components (LEDs, etc.) configured.

I am unable to tell the project with my .ino file in it to use the code in the "library" folder - I have to copy my .cpp/.h files to a folder in the arduino libraries folder after every change.  I also have to open my .ino in the Arduino IDE and build/save it once for VisualStudio/VisualMicro to be able to fine the arduino.h file.  NOTE that even though the VS EDITOR cannot resolve references (e.g. uint8_t) I can compile and deploy to the hardware without a problem.

I feel like I could manually edit the configuration file and manually change things but this would likely be overwritten.

What I want is for my new "library" code to resolve as code included in my project, but act like library code (e.g. #include path resolution and resolution to other "true" libraries I am using).
« Last Edit: Jun 28th, 2018 at 7:36pm by JoeBloe »  
Back to top
 
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12187
Location: United Kingdom
Joined: Apr 10th, 2010
Re: Path trouble developing arduino library
Reply #5 - Jun 28th, 2018 at 7:44pm
Print Post  
I suggest you start with a real arduino library and understand how that side of arduino works before trying your own solutions.

For the arduino ide a library must be placed in the sketchbook\libraries folder which is normally mydocuments\arduino\libraries

The library must conform to the arduino 1.5.x library specification.

Visual Micro does allow you to create arduino libraries in any location but you should use that location to start with.

Notice on the "Add Library" menu visual micro has an option to create a project when adding a library. This will show you how to add a shared project to the solution to make library development easier. You will read in the readme.txt how to "add the shared lib project" to your arduino project in visual studio so that intellisense and development in the ide works better.

If you switch on the verbose option you will see that Arduino projects are built in a temp folder after all the .ino files have been combined into a .cpp file. So you can't just put files anywhere.

If you wanted to avoid an arduino library there are simpler ways, in visual micro, to include .h/.cpp files as short cuts but the short cuts are copied to and built in the temp build folder with the other sources so unless you are clear about how arduino works you won't understand how to make the #includes in the code. 

Another option you will find on the "file>new>project>c++" menu is that visual micro provides a way to create "shared c++ projects" for arduino. This is a special project that both VS and Visual Micro understand that can be shared between arduino projects. Shared projects can contain .cpp/.h etc. in unlimited sub folders. You need to follow the readme.txt in the project after creation to understand how to use in visual studio. shared project sources are merged into the temp build folder at build time. The root of the merged folders is always into the root of the temp build folder. 

« Last Edit: Jun 28th, 2018 at 7:48pm by Tim@Visual Micro »  
Back to top
IP Logged
 
JoeBloe
Newbies
*
Offline


Posts: 4
Joined: Jun 24th, 2018
Re: Path trouble developing arduino library
Reply #6 - Jul 2nd, 2018 at 8:50pm
Print Post  
Thanks.  Setting up a  "shared c++ projects" for arduino" is exactly what I am looking for.
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint