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 Migrating to Visual Micro from Visual Studio Code (Read 3321 times)
Joshua Gall
Junior Member
**
Offline


Posts: 15
Joined: Nov 16th, 2018
Migrating to Visual Micro from Visual Studio Code
Nov 16th, 2018 at 4:04pm
Print Post  
hello,

I've got an arduino project that I've been building with Visual Studio code. It's composed of a library project and the sketch project, both in the standard arduino locations (documents/arduino/libraries and documents/arduino respectively).

The library references several other libraries, many of them from adafruit, which also live in the libraries folder. The library I made conforms to the arduino standard and has a library.properties file, src directory, and a .h file for the library itself. My source code is organized into sub-directories of the the src directory. You can see this project in my github repository: https://github.com/SirkleZero/workshop-climate-lib

My sketch is located at documents/arduino and is pretty straight forward. It references my custom library that I've made and has some simple functionality. You can find my sketch project in this github repository: https://github.com/SirkleZero/workshop-climate-controller

Background on the project structure aside, I'd like to use Visual Studio / Visual Micro since I use Visual Studio professionally and am much more comfortable with it's features. Unfortunately, I'm having a great deal of difficulty getting my project to compile in Visual Micro. For clarity sake, compiling with the native arduino ide and with Visual Studio Code work perfectly fine.

Here's what I've tried:
  1. Open my ino file with visual micro, and create a project from it when I'm asked. This compiles awesome!
  2. Next, to be able to edit my library files in the same IDE, add my custom library by clicking on Add Library, picking my library, and checking the Create Shared Project option. This also compiles perfectly fine, but obviously doesn't have any intellisense. As a side note, when it adds my files to the shared library project I loose my nice folder structure under src, and see my files all at the root of the project. Kinda sucky, but it works.
  3. Finally, to get intellisense working, I create a reference in my sketch project to my shared library project, and this is where things fall apart. Intellisense works perfectly fine, however I can no longer compile the project. For example, I get the following error: "Adafruit_SSD1306.h: No such file or directory" on my line where I'm including that library, "#include <Adafruit_SSD1306.h>"


I'm stumped by this last bit, where things stop compiling. I've attached the verbose build output, but I'm struggling to find where it's falling down.

Any guidance would be greatly appreciated.
  

Please Register or Login to the Forum to see File Attachments
Back to top
 
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12076
Location: United Kingdom
Joined: Apr 10th, 2010
Re: Migrating to Visual Micro from Visual Studio Code
Reply #1 - Nov 16th, 2018 at 7:40pm
Print Post  
Hi

Quote:
As a side note, when it adds my files to the shared library project I loose my nice folder structure under src, and see my files all at the root of the project. Kinda sucky, but it works.


Visual studio has a small icon above the solution explorer called "Show all files". The button toggles between physical file/folder view and collective view. You are currently in "Collective View" pls click the button.



Which board do you have?
  
Back to top
WWW  
IP Logged
 
Joshua Gall
Junior Member
**
Offline


Posts: 15
Joined: Nov 16th, 2018
Re: Migrating to Visual Micro from Visual Studio Code
Reply #2 - Nov 16th, 2018 at 11:29pm
Print Post  
Current board is an Adafruit Feather M0 WiFi.

thanks for the tip on the Collective View feature, I missed that!
  
Back to top
 
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12076
Location: United Kingdom
Joined: Apr 10th, 2010
Re: Migrating to Visual Micro from Visual Studio Code
Reply #3 - Nov 17th, 2018 at 6:11pm
Print Post  
Thanks for the report, I missed your build output in your first post which shows your board. 

The issue is that deep search is failing to scan shared libraries. Therefore is not automatically discovering and resolving library #includes referenced in the cpp code.

As a workaround before the next release you can force libraries to be discovered by adding an #include for them in theĀ  sketch.ino or a cpp file of the main project

For example this .ino code allows your lib to compile.

Code
Select All
//.ino code
#include <ArduinoHttpClient.h>
#include <AdafruitIO_WiFi.h>
#include <AdafruitIO_MQTT.h>
#include <AdafruitIO.h>
#include <Adafruit_ILI9341.h>
#include <SD.h>
#include <ArduinoJson.hpp>
#include <ArduinoJson.h>
#include <Adafruit_Sensor.h>
#include <ArduinoHttpClient.h>
#include <Adafruit_BME280.h>
#include <SPI.h>
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
#include <RH_RF69.h>
#include <RHReliableDatagram.h>
#include <workshop-climate-lib.h>

void setup()
{


}

// Add the main program code into the continuous loop() function
void loop()
{


} 


« Last Edit: Nov 17th, 2018 at 6:12pm by Tim@Visual Micro »  
Back to top
WWW  
IP Logged
 
Joshua Gall
Junior Member
**
Offline


Posts: 15
Joined: Nov 16th, 2018
Re: Migrating to Visual Micro from Visual Studio Code
Reply #4 - Nov 18th, 2018 at 3:58pm
Print Post  
Quote:
As a workaround before the next release you can force libraries to be discovered by adding an #include for them in theĀ  sketch.ino or a cpp file of the main project


That will work for now, I'll give it a shot tonight!

Did I find a defect by chance? I thought I was going a bit crazy there for a moment! If so, this was on Visual Studio 2017 Community Edition.
  
Back to top
 
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12076
Location: United Kingdom
Joined: Apr 10th, 2010
Re: Migrating to Visual Micro from Visual Studio Code
Reply #5 - Nov 19th, 2018 at 1:03pm
Print Post  
Sorry forgot to update this thread to say there is an interim release with a fix in the latest thread here

https://www.visualmicro.com/forums/YaBB.pl?board=VS_ARDUINO_EXT_RELEASES

Yes, it was a bug when accessing other libraries that are not shared lib projects from within the code of a shared lib project if the "other libs" were not also used within the main sketch/project code.

A useful reports thanks!
  
Back to top
WWW  
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12076
Location: United Kingdom
Joined: Apr 10th, 2010
Re: Migrating to Visual Micro from Visual Studio Code
Reply #6 - Nov 24th, 2018 at 11:12pm
Print Post  
Sorry I made a mistake. The change was not in 1811.17 it is now in the "work in progress" section 1811.24

The update discovers external lib references in shared libs that are not referenced from project code, also support debug of shared library cpp code.
« Last Edit: Nov 25th, 2018 at 12:09am by Tim@Visual Micro »  
Back to top
WWW  
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint