Welcome, Guest. Please Login or Register
Arduino IDE for Visual Studio
 
 
When Logging a Support Issue in the Forum, please ensure you have also:-
  • Enabled vMicro > Compiler > Show Build Properties and Verbose
  • Re-Compile your program with these settings enabled
 
Save the new Output to a Text File and....
Support requests without the output above may be impossible to answer, so please help us to help you
 
  HomeSearch Tutorials & Wiki visualmicro.com LoginHelpRegister  
 
Page Index Toggle Pages: 1
Send Topic Print
Re: fatal error: asf.h: No such file or directory (Read 2851 times)
davidml
Newbies
*
Offline



Posts: 6
Re: fatal error: asf.h: No such file or directory
Dec 18th, 2017 at 11:38pm
 
Hello,
I am having the exact same problem but I didn't upgrade the project, I created a new project in Atmel Studio 7.0.1645 and Arduino IDE for Atmel Studio 7 version 1709.3.1.  I solved it by forcing the compiler to include the path to the include file even though it is already listed in the Project -> Properties -> Toolchain -> C++ Compiler -> Directories and C Compiler -> Directories setting.  To force it to be included in the compile command I clicked on the project and then went to the menu item vMicro -> Project Properties and found the setting Micro General and added -I"C:/Program Files (x86)/Arduino/hardware/arduino/avr/libraries/Wire/src/utility" to "Extra c flags" and "Extra cpp flags". 

What confuses me is why the compile command doesn't include all the directories listed under Toolchain -> C Compiler and Toolchain -> C++ Compiler in the compile command.  I got Verbose compile output and sure enough it includes C:/Program Files (x86)/Arduino/hardware/arduino/avr/libraries/Wire/src but not the utility subdirectory C:/Program Files (x86)/Arduino/hardware/arduino/avr/libraries/Wire/src/utility. 

To get this library into my project I right clicked on the project and selected Add Arduino Library, selected the Arduino IDE Path and found the Wire library under  >AVR and clicked Add.  But not only did it add the two paths "C:/Program Files (x86)/Arduino/hardware/arduino/avr/libraries/Wire/src" and "C:/Program Files (x86)/Arduino/hardware/arduino/avr/libraries/Wire/src/utility" to the Toolchain Directories, it also copied the source code into my project.  This caused a second problem where the linker complained because the Classes were now defined twice.  So I deleted the files that it copied into my project and it compiled and linked. 

This was a tremendous amount of hacking to figure out how to solve it these problems, I can't believe any novice programmers would be able to figure this all out.  I only did it so I could run my program in the debugger.  I had the program running fine in Atmel Studio but their simulated debugger doesn't work well when you start adding libraries that talk to external peripherals like DS3231 Real Time Clocks and RN42 Bluetooth connections.  And the Visual Micro debugger wasn't available in my other project. 

So that is a good question, why can't I run the debugger in my other Atmel Studio projects? 

Thanks in advance for any info you can provide. 
Back to top
 
 
IP Logged
 
Visual Micro
Administrator
*****
Offline



Posts: 10142
United Kingdom
Re: fatal error: asf.h: No such file or directory
Reply #1 - Dec 19th, 2017 at 12:00am
 
Hi,

I think there is some confusion. Asf.h is not part of the arduino framework and I think you might be a little confused about arduino compatibility.

When we confirm you are working with an arduino project we will also find that all include paths for valid arduino libraries are added automatically.

The atmel project properties are not relevant and are automatically set purely to force intellisense to work

Arduino uses it's own method for compilation that atmel does not understand so it is important to post the compiler output so we can ensure you are not actually using an atmel c++ project instead of an arduino c++ project.

An arduino project will contain a project_name.ino

The debug discussion is simple but best left till we have a known environment and way of working.

Visual Micro works the same way as the arduino ide. Libraries are auto discovered.

Back to top
 
WWW  
IP Logged
 
davidml
Newbies
*
Offline



Posts: 6
Re: fatal error: asf.h: No such file or directory
Reply #2 - Dec 19th, 2017 at 12:10am
 
Quick update, I was able to recreate this problem and as it turns out it has everything to do with the fact that when I right click the project and choose Add Arduino Library and add my libraries to my project it copies the source code from these libraries into my project under src and include.  This is the error I get when I included the Chronos library.

Calendar.cpp: 26:42: fatal error: chronosinc/schedule/Calendar.h: No such file or directory
   #include "chronosinc/schedule/Calendar.h"
   compilation terminated

     An error was encountered during the 'Deep Search' library discovery process.
Debug build failed for project 'MyTestProject'

I can eliminate this error by forcing the compiler to include the path to chronosinc/schedule/Calendar.h via the Extra c flags and Extra cpp flags, but I still end up with a link error.  But if I simply delete the directory hierarchies "include" and "src" from my project it compiles and links just fine without adding the Extra c flags and Extra cpp flags.

So my question now is, am I adding the Arduino libraries to my project incorrectly?  I tried to add them as I usually do via Atmel Studio, right click on the Project -> Libraries and choose Add.  When I add them that way I also manually add the Include directories to Toolchain -> C Compiler and Toolchain -> C++ compiler but that doesn't work with Visual Micro as it overwrites any edits I perform to this setting.

What is the correct way to add an Arduino library to a Visual Micro Arduino project?

Here is the complete compiler output for a newly created Visual Studio Arduino project after I added a few Arduino libraries.
Back to top
 
 
IP Logged
 
Visual Micro
Administrator
*****
Offline



Posts: 10142
United Kingdom
Re: fatal error: asf.h: No such file or directory
Reply #3 - Dec 19th, 2017 at 1:00pm
 
Thanks for the posts. You can attach output as a .txt file when you click "Reply" in this forum. The quick post is confusing and does not provide option to attach a file.

Atmel studio might be confusing things here. In the past it has no arduino capability but more recently atmel is trying to get people to convert their arduino projects to gcc/c++. I think the menu you are using is an atmel menu that attempts to include the arduino library as it would expect with gcc.  If the menu item has an arduino icon then ignore it because that is atmel confusing things! It is also the reason that I now recommend visual studio over atmel studio

Please use the visual micro menu "vMicro>Add Library" or the Visual Micro tool bar command to add libraries

Thanks
Back to top
 
WWW  
IP Logged
 
davidml
Newbies
*
Offline



Posts: 6
Re: fatal error: chronosinc/schedule/Calendar.h: No such file or directory
Reply #4 - Dec 19th, 2017 at 6:50pm
 
Sorry about the long output post.  I didn't think to attach a txt file  Undecided 

And I see now that my error was different than "fatal error: asf.h: No such file or directory". My error was using the right click -> Add Arduino Library to add the library which creates the same error but with a different file ("fatal error: chronosinc/schedule/Calendar.h: No such file or directory")  I see now that if I create an Arduino project via New->Arduino Project ALL the installed Arduino libraries are automagically added and I simply need to include the headers I need and the correct libraries will link. 

It has been so long since I used the Arduino IDE I have been used to doing everything by hand in Atmel Studio.  I have multiple compiled cores for each different architecture I use for different projects and I have both Debug and Release versions of libraries compiled.  I have a lot of cleanup I can do once I convert my projects to Visual Micro.  This really does make things much easier once I stop trying to man handle the build Grin

Thank you for replying to my post and I see also if I change the name of my Sketch.cpp to Sketch.ino it will convert it to a Visual Micro project and I can use the debugger. 

On my way again!  Thank!
Back to top
 
 
IP Logged
 
Visual Micro
Administrator
*****
Offline



Posts: 10142
United Kingdom
Re: fatal error: asf.h: No such file or directory
Reply #5 - Dec 20th, 2017 at 1:09am
 
Great thanks. Yes it's very confusing. Thanks Atmel  Angry
Back to top
 
WWW  
IP Logged
 
Visual Micro
Administrator
*****
Offline



Posts: 10142
United Kingdom
Deep search: fatal error: asf.h: No such file or directory
Reply #6 - Sep 25th, 2018 at 8:16pm
 
Off-Topic replies have been moved to this Topic.
Back to top
 
WWW  
IP Logged
 
Page Index Toggle Pages: 1
Send Topic Print