Visual Studio Ide for Arduino
https://www.visualmicro.com/forums/YaBB.pl
Other >> Arduino for Visual Studio 2010 >> Libraries include problem
https://www.visualmicro.com/forums/YaBB.pl?num=1432901648

Message started by CPJ on May 29th, 2015 at 1:14pm

Title: Libraries include problem
Post by CPJ on May 29th, 2015 at 1:14pm
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"

Title: Re: Libraries include problem
Post by Visual Micro on May 29th, 2015 at 1:30pm
Hi,

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

Thanks

Title: Re: Libraries include problem
Post by CPJ on May 29th, 2015 at 2:39pm
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

Title: Re: Libraries include problem
Post by Visual Micro on May 29th, 2015 at 2:42pm
Arduino.h is not a library

Does it work in the Arduino Ide?

Title: Re: Libraries include problem
Post by CPJ on May 29th, 2015 at 2:51pm
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.


Title: Re: Libraries include problem
Post by Visual Micro on May 29th, 2015 at 2:57pm
I'll try it over the weekend

Thanks for all the info

Title: Re: Libraries include problem
Post by CPJ on May 29th, 2015 at 3:03pm
The #include "Arduino.h" is from here:
http://www.arduino.cc/en/Hacking/LibraryTutorial

Thanks.

Title: Re: Libraries include problem
Post by Visual Micro on May 29th, 2015 at 3:05pm
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.

Title: Re: Libraries include problem
Post by Visual Micro on May 30th, 2015 at 2:33pm
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]#include <Wire.h>
#include <SPI.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
[/code]

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)

Title: Re: Libraries include problem
Post by Visual Micro on May 30th, 2015 at 2:51pm
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

Title: Re: Libraries include problem
Post by CPJ on Jun 2nd, 2015 at 4:00pm
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

Title: Re: Libraries include problem
Post by CPJ on Jun 2nd, 2015 at 4:17pm
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

Title: Re: Libraries include problem
Post by Visual Micro on Jun 2nd, 2015 at 6:06pm
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

Title: Re: Libraries include problem
Post by CPJ on Jun 2nd, 2015 at 7:04pm
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.

Title: Re: Libraries include problem
Post by Visual Micro on Jun 2nd, 2015 at 7:06pm
Great, thanks for the update.

Visual Studio Ide for Arduino » Powered by YaBB 2.5.2!
YaBB Forum Software © 2000-2019. All Rights Reserved.