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) Libraries include problem (Read 16866 times)
CPJ
Newbies
*
Offline


Posts: 7
Joined: May 29th, 2015
Libraries include problem
May 29th, 2015 at 12:14pm
Print Post  
Hi, 

I have installed some libraries into Visual Micro (using Visual Micro Explorer), inside Visual Studio. The same libraries I have installed into Arduino IDE.
If I #include Wire.h inside the .ino file it wil compile.
If the same library (Wire.h) is included inside another library either being made by me or by some else like Adafruit_SSD1306 library it will not compile with fatal error: Wire.h: No such file or directory

Of course gives the same error for #include "Adafruit_SSD1306.h"
« Last Edit: May 29th, 2015 at 12:17pm by CPJ »  
Back to top
 
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12076
Location: United Kingdom
Joined: Apr 10th, 2010
Re: Libraries include problem
Reply #1 - May 29th, 2015 at 12:30pm
Print Post  
Hi,

It's difficult to work out from your 2nd report if you have included wire.h in your sketch or not?

Thanks
  
Back to top
WWW  
IP Logged
 
CPJ
Newbies
*
Offline


Posts: 7
Joined: May 29th, 2015
Re: Libraries include problem
Reply #2 - May 29th, 2015 at 1:39pm
Print Post  
By same error I mean fatal error: Adafruit_SSD1306.h: No such file or directory.

I give some exact examples:

#1 In .ino 
#include <Wire.h>
it will compile

#2 In .ino 
#include <SPI.h> 
it will compile

#3 In .ino 
#include "Adafruit_SSD1306.h"
or 
#include <Adafruit_SSD1306.h>
For either of these I get the following two errors:
Adafruit_SSD1306.h:35:17: fatal error: SPI.h: No such file or directory
Adafruit_SSD1306.cpp:25:18: fatal error: Wire.h: No such file or directory


#4 In .ino 
#include "<MyLibrary.h>"
and in MyLibrary.h
#include "Arduino.h"
#include "Wire.h"

I get (either with <> or "" for #include) the error: 
MyLibary.h:2:18: fatal error: Wire.h: No such file or directory
So no error for #include Arduino.h inside MyLibrary.h

Every script works in the same Arduino IDE that is used by Visual Micro
« Last Edit: May 29th, 2015 at 1:43pm by CPJ »  
Back to top
 
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12076
Location: United Kingdom
Joined: Apr 10th, 2010
Re: Libraries include problem
Reply #3 - May 29th, 2015 at 1:42pm
Print Post  
Arduino.h is not a library

Does it work in the Arduino Ide?
  
Back to top
WWW  
IP Logged
 
CPJ
Newbies
*
Offline


Posts: 7
Joined: May 29th, 2015
Re: Libraries include problem
Reply #4 - May 29th, 2015 at 1:51pm
Print Post  
Yes everything works inside the same Arduino IDE used by Visual Micro.

Arduino IDE 1.6.4 with libraries installed through Library Manager
Visual Studio 2013 Professional 12.0.31101.00 Update 4 with all extensions updated
I can't find the version of Visual Micro but it is the first final release (no RC) that worked with Arduino 1.6.4. Can't figure out if is 1505.19 Sp2. No update info when started Visual Studio.

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


Posts: 12076
Location: United Kingdom
Joined: Apr 10th, 2010
Re: Libraries include problem
Reply #5 - May 29th, 2015 at 1:57pm
Print Post  
I'll try it over the weekend

Thanks for all the info
  
Back to top
WWW  
IP Logged
 
CPJ
Newbies
*
Offline


Posts: 7
Joined: May 29th, 2015
Re: Libraries include problem
Reply #6 - May 29th, 2015 at 2:03pm
Print Post  
The #include "Arduino.h" is from here:
http://www.arduino.cc/en/Hacking/LibraryTutorial

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


Posts: 12076
Location: United Kingdom
Joined: Apr 10th, 2010
Re: Libraries include problem
Reply #7 - May 29th, 2015 at 2:05pm
Print Post  
It is correct and normal to include the arduino.h header in cpp/h files.

I only mentioned it because you mentioned it was not causing an error.
  
Back to top
WWW  
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12076
Location: United Kingdom
Joined: Apr 10th, 2010
Re: Libraries include problem
Reply #8 - May 30th, 2015 at 1:33pm
Print Post  
Hi,

Before I test with a custom library I need to clear up some questions.

I installed the SSD1306 library and tested with both Arduino 1.6.4 and the latest Visual Micro.

In both cases the following includes in the main sketch.ino were required for a successful compile.

Code
Select All
#include <Wire.h>
#include <SPI.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
 



If wire, spi or gfx #includes are missing then both ide's failed to compile. I had to install the gfx library.

By the way it doesn't matter if you use quotes " or chevrons <> to #include but the Project>Add>Import Arduino library" will insert the syntax that Arduino uses. 

+ you were right to #include arduino.h in your library code. when I first read your message I thought you had included it in the .ino code.

It would be help if you switched on tools>options>visual micro>compiler> "verbose" and "show build properties", then click "build>clean solution", then click Build and email or attach the output (info [at] visualmicro.com)
« Last Edit: May 30th, 2015 at 1:52pm by Tim@Visual Micro »  
Back to top
WWW  
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12076
Location: United Kingdom
Joined: Apr 10th, 2010
Re: Libraries include problem
Reply #9 - May 30th, 2015 at 1:51pm
Print Post  
Hi,

Please see my note below questioning the use of gfx etc.

I have now tested with a new library and it works both in visual micro and the arduino ide

I can only assume you are using a different sketch book location in visual micro compared to the arduino ide. The sketchbook location is used to find contributed libraries. 

Can you confirm the sketch book location in the visual micro ide locations window IS empty? (This would mean we are using the same as the arduino ide which is good)

Please submit the build output as described below with both "verbose" and "show build properties" enabled.

Thanks

ps: The visual micro version is shown in tools>options>visual micro>version + minor
« Last Edit: May 30th, 2015 at 1:52pm by Tim@Visual Micro »  
Back to top
WWW  
IP Logged
 
CPJ
Newbies
*
Offline


Posts: 7
Joined: May 29th, 2015
Re: Libraries include problem
Reply #10 - Jun 2nd, 2015 at 3:00pm
Print Post  
Hi,

I have sent you two emails. First one contains only the otput when no #include statements are inside the .ino file.
The second email contains both situations with the #include and without the #include statements (identical to previous email).
Friday I have reinstalled Visual Micro (1505.19 sp2).
The reinstall and Clean Solution helped alot. Before I had to create Property Sheets for Aditional Include Directories for each library used. After removing all sheets and than Cleanin Solution, it automatically added all these directories into the project properties. Now there is a new issues that you can see into the attached .txt file of the second email.

Now I will try again with sp4 and if solved I will get back with news.

Thanks,
Cosmin
  
Back to top
 
IP Logged
 
CPJ
Newbies
*
Offline


Posts: 7
Joined: May 29th, 2015
Re: Libraries include problem
Reply #11 - Jun 2nd, 2015 at 3:17pm
Print Post  
So, the same error I get with sp4, but also with Arduino IDE. So this is not related to Visual Micro. I will look into this further.

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


Posts: 12076
Location: United Kingdom
Joined: Apr 10th, 2010
Re: Libraries include problem
Reply #12 - Jun 2nd, 2015 at 5:06pm
Print Post  
I am not sure I fully understand your issue but the adafruit header files appear to have a mistake

The .h code should be wrapped in

#ifndef ADAFRUIT_SOMETHING
#define ADAFRUIT_SOMETHING

//header code

#endif

Otherwise I think you will see the error you see which tells you the object is already defined. This is because it is included in the .ino and in your .cpp file.

I think you should log this in the adafruit site and see what they say
  
Back to top
WWW  
IP Logged
 
CPJ
Newbies
*
Offline


Posts: 7
Joined: May 29th, 2015
Re: Libraries include problem
Reply #13 - Jun 2nd, 2015 at 6:04pm
Print Post  
It seems there was a old project cleanup issue. This project was started with some older Visual Micro builds and after cleanup it worked properly. The Additional Include Directories were not updated with all libraries paths, so I had to always reference from main library directory. That is, if #include <Wire.h> was needed, I would have to write #include <Wire/Wire.h> and that broke the Adafruit_1306.cpp #include <Wire.h> statement.

The test I have made and replayed here, were all done with the same Visual Micro build. In disperation and frustration of finding a solution, things got mixed up for me too. 

The install of newer sp2 bulild and the suggested build>clean solution, made the old project work properly. It added all needed directories to Additional Include Directories. So problem is solved.

There is a issue with Adafruit_1306 library as you mentioned and I will report it to them. 

Thank You very much for Your help.
  
Back to top
 
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12076
Location: United Kingdom
Joined: Apr 10th, 2010
Re: Libraries include problem
Reply #14 - Jun 2nd, 2015 at 6:06pm
Print Post  
Great, thanks for the update.
  
Back to top
WWW  
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint