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) How to use local project libraries? (Read 11027 times)
bc547
Newbies
*
Offline


Posts: 9
Joined: Aug 27th, 2016
How to use local project libraries?
Aug 27th, 2016 at 4:32pm
Print Post  
I've read http://www.visualmicro.com/post/2015/10/24/Advanced-Arduino-Local-Libraries-and-... and http://www.visualmicro.com/page/Local-Project-Arduino-API-Source.aspx but cannot get local project libraries to work.

I'm trying to compile the following sketch https://github.com/milesburton/Arduino-Temperature-Control-Library/blob/master/e...

This is my directory structure:
Code
Select All
sensor/
    sensor.ino                   # contains the sketch code mentioned above
    src/_micro-api/libraries/
                            DallasTemperature/
                                             DallasTemperature.h
                                             ....
                            OneWire/
                                             OneWire.h
                                             ....
 



The error I get is:
Code
Select All
sensor.ino: 3:21: fatal error: OneWire.h: No such file or directory
   #include "OneWire.h"
   compilation terminated


	An error was encountered during the 'Deep Search' discovery process.
	Either resolve the error or switch off the 'Deep Search Includes' option.
	Tip: When deep search is switched off, headers must be #included in the [project_name.ino] for all required libraries (for example: #include <SPI.h>)
	Tip: Deep search must be off if the project source contains links/shortcuts to code outside of the project structure. The source will have been #included using a relative path preceeded by ..\ (for example: #include "..\..\foo\foo.h")
 



I tried disabling deep search via menu vMicro->Compiler->Deep Search Includes, but it seems I cannot disable it? I cannot get rid of the checkbox.


Any advice about what I'm doing wrong?
  
Back to top
 
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12163
Location: United Kingdom
Joined: Apr 10th, 2010
Re: How to use local project libraries?
Reply #1 - Aug 27th, 2016 at 5:20pm
Print Post  
Hi,

Which Ide and version of Visual Micro? The Visual micro version is in "tools>extensions and updates"

Thanks
  
Back to top
IP Logged
 
bc547
Newbies
*
Offline


Posts: 9
Joined: Aug 27th, 2016
Re: How to use local project libraries?
Reply #2 - Aug 27th, 2016 at 5:36pm
Print Post  
Tim@Visual Micro wrote on Aug 27th, 2016 at 5:20pm:
Hi,
Which Ide and version of Visual Micro? The Visual micro version is in "tools>extensions and updates"


IDE: Microsoft Visual Studio Community 2015 (Version 14.0.25425.01 update 3)
Visual Micro: Version 1608.25.0 (Installed 8/27/2016), Licenced
Arduino IDE: v1.6.11
  
Back to top
 
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12163
Location: United Kingdom
Joined: Apr 10th, 2010
Re: How to use local project libraries?
Reply #3 - Aug 28th, 2016 at 2:12am
Print Post  
Hi,

yes couple of strange things to look into.

if you #include the libraries you want to use in the [project_name].ino source that will resolve it.

Deep search should be automatically resolving the libraries uses in libraries but seems to be failing to do that with local libraries. However adding #includes to the .ino code removes the need for deep search and is how arduino used to work until a few months ago.

I am not sure why you can switch off deep search. I will have to add some additional trace messages
  
Back to top
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12163
Location: United Kingdom
Joined: Apr 10th, 2010
Re: How to use local project libraries?
Reply #4 - Aug 28th, 2016 at 11:47pm
Print Post  
Hi,

I tried this out and can't get it to go wrong.

So I could do with some info.

Please switch on vmicro>compiler>verbose and "show build properties" and then build and post the output as a .txt file or email to info[at]visualmicro.com with a link back to this post

A screen shot of the solution explorer showing the library folder and file structure would also be useful thanks

Thanks
« Last Edit: Aug 29th, 2016 at 1:45am by Tim@Visual Micro »  
Back to top
IP Logged
 
bc547
Newbies
*
Offline


Posts: 9
Joined: Aug 27th, 2016
Re: How to use local project libraries?
Reply #5 - Aug 30th, 2016 at 5:30pm
Print Post  
Tim@Visual Micro wrote on Aug 28th, 2016 at 11:47pm:
Hi,

I tried this out and can't get it to go wrong.




I found how to repoduce the inability to switch deepsearch on or off.
In visual studio, I have a solution (karmonitor) with 2 projects (sensor and console).

If the startup project is e.g. 'console', but I have sensor.ino open&active in the editor, I cannot change the deepsearch status. (it stays locked at the current setting).  If the file console.ino is open&active in the editor, it is no problem to change the deepsearch status.

If the startup project is set to 'sensor', the behaviour is reversed: changeable from sensor.ino, locked if console.ino is active.





About the local library issue: I'm still trying out some stuff. I got it to work somehow after lots of experimenting, but I'm not sure if it is supposed to work like that. Documenting/reproducing it now. More feedback later Smiley
  
Back to top
 
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12163
Location: United Kingdom
Joined: Apr 10th, 2010
Re: How to use local project libraries?
Reply #6 - Aug 30th, 2016 at 5:50pm
Print Post  
Excellent thanks
  
Back to top
IP Logged
 
bc547
Newbies
*
Offline


Posts: 9
Joined: Aug 27th, 2016
Re: How to use local project libraries?
Reply #7 - Aug 30th, 2016 at 7:33pm
Print Post  
The local library part:

This is what I currently do:

Create Project
  • Open Visual Studio 2015
  • vMicro -> New Arduino Project
  • Name it 'test1'
    (In my case, the path is C:\Users\u0022948\Documents\Arduino\test1, Deep Search Includes is On)


Get library
  • Create _micro-api directory C:\Users\u0022948\Documents\Arduino\test1\src\_micro-api\libraries
  •  Download the OneWire arduino library http://www.pjrc.com/teensy/arduino_libraries/OneWire.zip into the src\_micro-api\libraries directory
  •  Extract the zipfile. 
    (The libraries directory should now have a subdirectoy called OneWire with OneWire.h and OneWire.c and an examples directory in it)


Setup test1.ino
  •  Copy the contents of the OneWire example file les\DS18x20_Temperature\DS18x20_Temperature.pde 
  •  Paste the content into the test1.ino file (replacing whatever was in the test1.ino file). A '#include <OneWire.h>' is present in the test1.ino file


If I try to build at this stage, I get:
Code
Select All
test1.ino: 2:21: fatal error: OneWire.h: No such file or directory
   #include <OneWire.h>
   compilation terminated
 



Next step I try to reload the toolchain (Tools->Visual Micro->Reload Toolchains)
In solution explorer, I right-click on 'test1' project and choose 'Clean'

Code
Select All
This still gives the same error:
test1.ino: 2:21: fatal error: OneWire.h: No such file or directory
   #include <OneWire.h>
   compilation terminated
 



Add header and source file to project
  •  In solution explorer: Right-click on 'Header Files' -> 'Add' -> 'Existing Item' -> Select src\_micro-api\libraries\OneWire\OneWire.h 
  •  In solution explorer: Right-click on 'Source Files' -> 'Add' -> 'Existing Item' -> Select src\_micro-api\libraries\OneWire\OneWire.cpp


Now building the project is succesful. (DeepSearch On or Off makes no difference, both work)


So my questions are:
     
  •   is this the recommended way of using local libraries (manually including the libraries .h, .cpp files in the project)?
  •   for libraries with multiple .h and .cpp files (e.g. RadioHead packet radio library http://www.airspayce.com/mikem/arduino/RadioHead/ ), each individual .h and .cpp file must be manually included in solution explorer?



I'm sorry if this is actually basic knowledge, I'm learning to use the IDE and am trying to find the 'right' way to setup a solution with multiple arduino projects Smiley
  
Back to top
 
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12163
Location: United Kingdom
Joined: Apr 10th, 2010
Re: How to use local project libraries?
Reply #8 - Aug 30th, 2016 at 8:43pm
Print Post  
Hi,

No its not recommended. Local libraries are for advanced users and you never need to create the _micro-api folder manually.

1. Delete the physical src folder

2. Remove the src folder from the solution explorer is it still exists.

Libraries are described in the arduino user guide but here are a few tips. The basics are the same in both ide's

1) Manually install a library from a zip using the "vMicro>Add Library>Install Library" which unpack the zip into your "sketch book\libraries folder" normally documents\arduino\libraries. You can also manually unzip your library into the correct location

2) Click the Refresh command on the same install library menu or restart the ide

3) Use the vMicro>Add Library" menu to select the newly installed library. This will add the correct format of #include to the project_name.ino but you can use the same syntax in cpp files.

Adding/using an arduino library in a project does not mean copying code into the local project. Libraries are never included with a path because they are automatically discovered from known areas.

As a simpler alternative to 1) use the "visual micro explorer > library manager" to locate, download and install libraries without messing with zip files.

Please see the Visual Micro document for more info. Here are two articles from the visulmicro.com documentation index

Adding libraries to your sketch: http://www.visualmicro.com/page/User-Guide.aspx?doc=Add-Libraries.html
Managing Libraries with Library Manager: http://www.visualmicro.com/page/User-Guide.aspx?doc=Library-Manager.html

After you add libraries to a sketch the code can be viewed easily using "vMicro>Toggle Hidden Files"

After installing a library use the Examples tab on the Micro Explorer to easily create a new cloned project of any example or create a new project and copy the code in manually like you did. The Examples tab gives both a way to clone or open an example and a way to view just the source code without creating a project

note

Most libraries can be compiled as project code. However Arduino recently started compiling all code found in the \src folder and below. So visual micro will shortly recommend moving the src\_micro-api to some other location. This is why arduino will appear to compile code in the \src folder but it compiles it as project code which isn't right. Another reason to stay away from the \src\_micro-api\ folder.

The vMicro>toggle hidden files creates shortcuts to to code instead of importing locally so is a safe way to see and explore the library sources without causing confusion in the arduino ide.
« Last Edit: Aug 30th, 2016 at 8:55pm by Tim@Visual Micro »  
Back to top
IP Logged
 
bc547
Newbies
*
Offline


Posts: 9
Joined: Aug 27th, 2016
Re: How to use local project libraries?
Reply #9 - Aug 31st, 2016 at 6:26am
Print Post  
Thank you for the extensive explanation.

The reason I want to use local libraries instead of user libraries, is because I want all used library code (except from the standard arduino core libraries) to be also included in my project git repo. Mainly because:

- I want my projects to always build when checked out. This is not guaranteed when depending on 'external' source code locations. Sometimes libraries disappear or get breaking changes.
- Sometimes I make changes to libraries that are specific for a project. Mostly when I'm running out of memory and need to trim down on code/ram size.


As far as I can tell, this is only possible with local libraries?
  
Back to top
 
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12163
Location: United Kingdom
Joined: Apr 10th, 2010
Re: How to use local project libraries?
Reply #10 - Aug 31st, 2016 at 7:11am
Print Post  
and thanks to you too for explaining.

Okay yes you are right you need local libraries.

There has been some huge changes in arduino over the past 6-9 months and things are only just now settling and maturing instead of changing.

Furthermore local libraries are relatively new but more importantly the deep search is a very new. I will test them more over the next few days now that some other jobs are complete.

To test/create a local library I suggest you create a new arduino project and then right click the project in the solution explorer and click "add>add code>new arduino library". That should #include the lib in the .ino and also create the physical files.

The .ino source should have #includes such as:-
#include <OneWire.h>
#include <MyLib.h>

I suggest you install the latest visual micro because there are some compiler cache fixes that will avoid a lot of confusion for someone who will be changing library sources. A release has just been uploaded.

There aren't usually so many updates but it's a busy time.
  
Back to top
IP Logged
 
bc547
Newbies
*
Offline


Posts: 9
Joined: Aug 27th, 2016
Re: How to use local project libraries?
Reply #11 - Sep 3rd, 2016 at 1:00pm
Print Post  
The local libraries now work fine for me.

Thank you again for the very quick and extensive advice!
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint