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) Compilation error in VM beta (1504.20 Sp3) (Read 9084 times)
garrison
Junior Member
**
Offline


Posts: 28
Joined: Mar 27th, 2015
Compilation error in VM beta (1504.20 Sp3)
Apr 29th, 2015 at 7:32pm
Print Post  
Hi!
I've got a compilation error with VM beta (1504.20 Sp3), Visual Studio 2013 and Arduino 1.6.3. The output is following:
...
System.Exception: Invalid or missing source path during compiler cache
c:\...\libraries\GLibs\src
...

The error is because of including my own libraries to the project, that are located in one subfolder: I have libraries\GLibs folder which contains some libraries, that I have written before (e.g. lib1.h+lib1.cpp, lib2.h+lib2.cpp and so on). When I include them to the main .ino file, the following code is used:
Code (C++)
Select All
#include <GLibs\lib1.h>
#include <GLibs\lib2.h>
... 



I know that this way of putting some libraries to one subfolder is not preffered, but it worked fine with previous versions of VM. It is not comfortable for me to put my libraries to different subfolders, as it expected to do, because they are code-dependent from each other.

How can I solve this issue?

Tried to create GLibs\src subfolder and move all libraries files there - not working too. The only way it works when files are located in GLibs folder AND GLibs\src subfolder.
  
Back to top
 
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12163
Location: United Kingdom
Joined: Apr 10th, 2010
Re: Compilation error in VM beta (1504.20 Sp3)
Reply #1 - Apr 29th, 2015 at 8:13pm
Print Post  
Hi,

In the last release there was a fix for the ArduinoJson library which compiled with the Arduino Ide but not with Visual Micro. This is probably resolved by following one of the two guidelines below.

Firstly, The error you getting is strange and it would be helpful if you zipped and emailed your library when it is in a state that produced the error. It might also be an idea to click "Build>Clean Solution" to clear the compiler cache after all the changes you have made to the layout of the library.

In earlier versions of visual micro, if a library contained an /src sub folder it was considered to be the new arduino 1.5.x library format otherwise it was considered to be an Arduino 1.0.x format library.

In the latest release, if any source code exists directly in the library folder then the library is considered an Arduino 1.0.x format library. This is how the Arduino Ide works.

1.0.x - Version 1 libraries

The source code of the library must reside in the main library folder, an optional \utility sub-folder is supported for "private" includes. The headers in the library folder (not the utility folder) are #included when adding the library to a sketch

1.5.x - Version 2 libraries

The root of the library must not contain any source code or header files. The source code of the library will be located in the \src sub folder. The \src sub folder may contain an unlimited number of additional "private" sub folders with as many levels of folder below \src as is required. When importing a library to a sketch the header files in the \src folder are #included.

General Library Best Practices

A library will ideally contain one .h header file with the same name as the library folder and that header file is #included in the sketch project main sketch [sketch_name].ino code. This makes it easier for Arduino and Visual Micro to resolve the correct library.

It is recommended that the Visual Micro menu "project>add/import sketch library" command be used to import libraries because this ensures the correct Arduino compatible #include syntax is used in the sketch code. 

For libraries that have conflicting header names or to use specific versions of libraries Visual Micro optionally supports qualifying the library name in the #include <LibName\LibName.h> or #include <LibName\Lib1.h>. Qualifying library names in #includes is not recommended because the code is not compatible with the Arduino Ide. The facility exists purely for experienced users to circumvent a weakness in the Arduino library design that is a result of the simplicity of the design (a benefit to most).

Multiple header files in libraries are supported

Summary

I hope this information helps but would still like a zip of the library sent to info [at] visualmicro.com

Thanks
« Last Edit: Apr 29th, 2015 at 8:17pm by Tim@Visual Micro »  
Back to top
IP Logged
 
garrison
Junior Member
**
Offline


Posts: 28
Joined: Mar 27th, 2015
Re: Compilation error in VM beta (1504.20 Sp3)
Reply #2 - May 1st, 2015 at 8:32am
Print Post  
Thaks for such a detailed answer! Now I understand the inner mechanism of how libraries are included. But I couldn't get my code working, so zipped you a source code example. Maybe you can help me with this Smiley

And I cannot understand one thing with libraries in Arduino. If I need, for example, to use mutual dependent libraries. How do I need to locate them in folders? Example: I have two libraries GPin and GLed. GLed is based on GPin, but both of them can be used in user source code.

Thank you!
« Last Edit: May 1st, 2015 at 8:32am by garrison »  
Back to top
 
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12163
Location: United Kingdom
Joined: Apr 10th, 2010
Re: Compilation error in VM beta (1504.20 Sp3)
Reply #3 - May 1st, 2015 at 2:58pm
Print Post  
I don't understand.

Create  library called myLibrary

Put a myLibrary.h in the folder it can be empty if that's easier for you.

Add more .h and cpp fiels to meet your needs.

Then use the "project>add/import library" to include the library in your sketch. Do not add #includes manually because then you will never learn the correct #include syntax.

If you want to move to two different libraries then create separate folders but import both libraries into the sketch.

You own lib code can use other libraries as long as you import them both into the sketch. This is how dependencies are resolved.

Hope that makes sense, to be clear here are the rules

1) Make sure your library is located in sketch\libraries
2) use Visual Micro to import your library into the sketch code. Do not manually add #includes until you know what you are doing.



« Last Edit: May 1st, 2015 at 3:02pm by Tim@Visual Micro »  
Back to top
IP Logged
 
garrison
Junior Member
**
Offline


Posts: 28
Joined: Mar 27th, 2015
Re: Compilation error in VM beta (1504.20 Sp3)
Reply #4 - May 2nd, 2015 at 4:49pm
Print Post  
Yes, I understand what you mean. But there are some inconveniences with this way of using libraries. I'll try to show them in example below.

Let's imagine that we have some auxiliary classes that represent complex data types: StackList, StackArray, BitVector and some others. Now we want to write a 2 libraries (Lib1 and Lib2), that will use all of these classes. The sketch code will use only Lib1 and Lib2, but not that auxiliary class data types (for example). 

How will we need to place all these libraries files? As I understand there are 3 ways to do this:
1. Make Lib1 and Lib2 subfolders in user libraries folder and put there respective LibX.h and LibX.cpp files. Make "private" subfolders in Lib1 and Lib2 folders and put there .h and .cpp files, that refer to respective auxiliary libraries, that are used in Lib1 or Lib2 libraries. 
This way has 2 disadvantages: 
- we will need to make copies of auxiliary libraries files. And to update (edit) them in the future we will need to update every copy
- we will not be able to use auxiliary libraries in main sketch code

2. Make Lib1 and Lib2 subfolders in user libraries folder, put there respective LibX.h and LibX.cpp files. Make StackList, StackArray, BitVector and other subfolders in user libraries folder for each auxiliary librariy, put there respective .cpp and .h files.
This way has 2 disadvantages:
- we will need to make subfolder for each auxiliary library (maybe lots of subfolders)
- we will need to #include every auxiliary library in main sketch code, that is used in Lib1 and Lib2, even if this auxiliary library is not used directly in main sketch.

3. Make LibPack subfolder (or smth like this) in user libraries folder, put there all .h and .cpp files for Lib1, Lib2 and other auxiliary libraries. This is how I tried to do before.
Advatages: 
- only 1 copy of each auxiliary library
- all working files are located in one folder, so it's easy to find them and redistribute
- need to #include only LibX.h file (via #include <LibPack\LibX.h>), but not all the auxiliary libraries, that are used in LibX
- every auxiliary library can be used in main sketch code
Disadvantage: doesn't work in official Arduino IDE

Which way is best? Maybe I'm missing smth and there are other ways, that remove all of these disadvantages?
  
Back to top
 
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12163
Location: United Kingdom
Joined: Apr 10th, 2010
Re: Compilation error in VM beta (1504.20 Sp3)
Reply #5 - May 2nd, 2015 at 4:53pm
Print Post  
I'm sorry I don't understand probably because my mind is on other things

1st I need to understand if you have decided to use v1 or v2 library format?

Then please explain why point 3) does not work providing a compiler output of any error?

3. Make LibPack subfolder (or smth like this) in user libraries folder, put there all .h and .cpp files for Lib1, Lib2 and other auxiliary libraries. This is how I tried to do before.
Advatages: 
- only 1 copy of each auxiliary library
- all working files are located in one folder, so it's easy to find them and redistribute
- need to #include only LibX.h file (via #include <LibPack\LibX.h>), but not all the auxiliary libraries, that are used in LibX
- every auxiliary library can be used in main sketch code

Thanks
  
Back to top
IP Logged
 
garrison
Junior Member
**
Offline


Posts: 28
Joined: Mar 27th, 2015
Re: Compilation error in VM beta (1504.20 Sp3)
Reply #6 - May 3rd, 2015 at 6:17am
Print Post  
I'm using v1 library format.
What about point 3) - I was wrong a bit - it works in official Arduino IDE with "#include <LibX.h>" (but it DOESN'T work for v2 library format). And doesn't work in latest beta releases of VM with v1 library format - that's why I have created this topic Smiley. Although I checked VM with v2 library format - and it works fine with "#include <GLibX.h>" (not "#include <GLibPack\GLibX.h>").

BTW, did you receive my zip file with example files?
« Last Edit: May 3rd, 2015 at 8:54am by garrison »  
Back to top
 
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12163
Location: United Kingdom
Joined: Apr 10th, 2010
Re: Compilation error in VM beta (1504.20 Sp3)
Reply #7 - May 3rd, 2015 at 5:24pm
Print Post  
Thanks for the report.

I have tested this and can confirm that if a v1 library is included in a project but there is not one #include with the name of the library then we get a compiler error.

Short term workaround is to simply create an empty.h of the same name and include it in the sketch above the other header files from the same library.

We will fix it but you should know that without a header file of the same name your library will always be prone to failing after new libraries are installed on your computer. 

#Includes from matching header/folder names get resolved first in a more accurate manner. Then it's pot luck as to which library folder is found containing matching header names.
  
Back to top
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12163
Location: United Kingdom
Joined: Apr 10th, 2010
Re: Compilation error in VM beta (1504.20 Sp3)
Reply #8 - May 3rd, 2015 at 6:46pm
Print Post  
Thanks again for all the info.

The problem is fixed in the next release. I found a workaround that you will feel is okay.

Create a GLibs.h and put it in GLibs

You do not need to include GLibs.h in your sketch. The bug in Visual Micro is looking for GLibs.h to assume the version of the library so as long as GLibs.h exists in the root of the library your code will work exactly as it did before.
  
Back to top
IP Logged
 
garrison
Junior Member
**
Offline


Posts: 28
Joined: Mar 27th, 2015
Re: Compilation error in VM beta (1504.20 Sp3)
Reply #9 - May 4th, 2015 at 12:01pm
Print Post  
Ok, that's great! Thank you a lot!  Smiley
  
Back to top
 
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12163
Location: United Kingdom
Joined: Apr 10th, 2010
Re: Compilation error in VM beta (1504.20 Sp3)
Reply #10 - May 4th, 2015 at 1:43pm
Print Post  
The release candidate is available on the downloads page
  
Back to top
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint