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 Having trouble with include paths and finding .h files (Read 5448 times)
textile
Newbies
*
Offline


Posts: 2
Joined: Aug 24th, 2016
Having trouble with include paths and finding .h files
Aug 24th, 2016 at 7:00pm
Print Post  
I've just started using Visual Micro (plugin for Atmel Studio) and am having trouble getting it to find some of my local libraries.  I've paid for the Pro version of Visual Micro, am using Atmel Studio 7.0.790, and Arduino.cc IDE 1.6.11.  The hardware is a custom Zero spinoff, and I had made a custom board type so that I could make changes to the Arduino ARM core in the Arduino IDE without affecting the standard Zero core.  For this project, I've also imported the core using Visual Micro.

In order to keep some cross-platform compiling capability, I've been manually adding #include lines at the top of my .ino files and locating .h files in the same folder as my Arduino sketch.  However, Visual Micro doesn't seem to be finding them.  It makes no difference whether Deep Search is on or off.  It seems to not look for libraries in the sketch include path.

I tried moving the files to the libraries folder under src and changing my #include "file.h" to #include <file.h>, but it still doesn't find them.  I noted it does not include ".../src/_micro-api/libraries" in the core include paths.

Where do I have to put my local libraries so that Visual Micro will find them?  Alternately, can I add ".../src/_micro-api/libraries" to the core include path?

Here's the error:
Quote:
Compiling 'Remora_SPDC_Sandbox' for 'Remora Marine Speed Controller (Native USB Port)'
Build folder: /cse_cse_samd_remora_marine_spdc
Summary: Header=1 Prototypes=4 Imports=1
Additional Defines: 
Architecture Tools: i-gcc\4.8.3-2014q1/bin/
Sketchbook: file:\\\C:\Users\LenoverUser\Documents\Arduino
Sketch Include Paths
Include Path 'C:\Users\LenoverUser\Documents\Atmel Studio\7.0\Remora_SPDC_Sandbox'
Core Include Paths
Include Path 'C:\Users\LenoverUser\Documents\Atmel Studio\7.0\Remora_SPDC_Sandbox/src/_micro-api/core'
Include Path 'C:\Users\LenoverUser\Documents\Atmel Studio\7.0\Remora_SPDC_Sandbox/src/_micro-api/variants/arduino_zero'
bi-gcc\4.8.3-2014q1\bin\arm-none-eabi-g++" -mcpu=cortex-m0plus -mthumb -c -g -Os -w -std=gnu++11 -ffunction-sections -fdata-sections -fno-threadsafe-statics -nostdlib --param max-inline-insns-single=500 -fno-rtti -fno-exceptions -w -x c++ -E -CC -DF_CPU=48000000L -DARDUINO=106011 -DARDUINO_SAMD_FEATHER_M0 -DARDUINO_ARCH_SAMD -DARDUINO_SAMD_ZERO -D__SAMD21G18A__ -DUSB_VID=0x239A -DUSB_PID=0x800B -DUSBCON -DUSB_MANUFACTURER="\"Remora Marine\"" -DUSB_PRODUCT="\"Speed Controller\"" .0-atmel/CMSIS/Include/" .0-atmel/Device/ATMEL/" -I"C:\Users\LenoverUser\Documents\Atmel Studio\7.0\Remora_SPDC_Sandbox/src/_micro-api/core" -I"C:\Users\LenoverUser\Documents\Atmel Studio\7.0\Remora_SPDC_Sandbox/src/_micro-api/variants/arduino_zero" e_samd_remora_marine_spdc\Remora_SPDC_Sandbox.cpp" -o "nul"
bi-gcc\4.8.3-2014q1\bin\arm-none-eabi-g++" -mcpu=cortex-m0plus -mthumb -c -g -Os -w -std=gnu++11 -ffunction-sections -fdata-sections -fno-threadsafe-statics -nostdlib --param max-inline-insns-single=500 -fno-rtti -fno-exceptions -w -x c++ -E -CC -DF_CPU=48000000L -DARDUINO=106011 -DARDUINO_SAMD_FEATHER_M0 -DARDUINO_ARCH_SAMD -DARDUINO_SAMD_ZERO -D__SAMD21G18A__ -DUSB_VID=0x239A -DUSB_PID=0x800B -DUSBCON -DUSB_MANUFACTURER="\"Remora Marine\"" -DUSB_PRODUCT="\"Speed Controller\"" .0-atmel/CMSIS/Include/" .0-atmel/Device/ATMEL/" -I"C:\Users\LenoverUser\Documents\Atmel Studio\7.0\Remora_SPDC_Sandbox/src/_micro-api/core" -I"C:\Users\LenoverUser\Documents\Atmel Studio\7.0\Remora_SPDC_Sandbox/src/_micro-api/variants/arduino_zero" e_samd_remora_marine_spdc\Remora_SPDC_Sandbox.cpp" -o "nul"
Remora_SPDC_Sandbox.ino:6:71: fatal error: Module_Init.h: No such file or directory
:#include "Module_Init.h"        // Functions for setting up digital IO
:compilation terminated
« Last Edit: Aug 25th, 2016 at 8:54pm by Tim@Visual Micro »  
Back to top
 
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12076
Location: United Kingdom
Joined: Apr 10th, 2010
Re: Also having trouble with include paths and finding .h files
Reply #1 - Aug 24th, 2016 at 8:31pm
Print Post  
Hi,

Thanks for buying pro. The free trial is always recommended Smiley

I think Visual Micro for Atmel is currently at Arduino 1.6.9 which is sometimes important. 1.6.10 and 11 have only recently been released so it always takes a few weeks before we submit a new gallery request with a new release.

Minor note: That said there should be much difference and because you are using the zero the core is a different download so again should be fine.

More importantly Visual Micro is Arduino compatible and works to the Arduino guidelines otherwise can't easily be supported.

The Arduino build rules are as follows:-

1) The Arduino Core is built into an archive files or as stipulated by the platform build definitions. The core build does not have access to library or project code.

2) The Libraries are built. The libraries have access to core include paths and include paths for all other included libraries

3) The project code is build having access to all related include paths.

Unless I have misunderstood, you are going to have difficulties trying to access project code from core, it's the wrong way around.

Because Arduino combines .ino code into a .cpp file prior to compile the compilation happens in a hidden temp folder. This means that the project code has to be copied to the temp folder and then compiled. This changes the include paths so requiring this automation is very difficult for users to have any control or affect over.

Lastly one thing that might help is to use the visual micro project property compiler extra flags. You can add include paths that will be applied to all build stages using the -I switch. But it doesn't support relative paths, does not affect what code is compiled, is simply a way to include some extra paths during build. Is a bit cumbersome and is for experienced users who can understand what the feature does. 
« Last Edit: Aug 24th, 2016 at 8:32pm by Tim@Visual Micro »  
Back to top
WWW  
IP Logged
 
textile
Newbies
*
Offline


Posts: 2
Joined: Aug 24th, 2016
Re: Also having trouble with include paths and finding .h files
Reply #2 - Aug 25th, 2016 at 5:24pm
Print Post  
Hi, Tim, thanks for your quick response.

I understand what you're saying about the core not having access to library or project code.  I was just trying to find some way of adding another include path for header files that the project code would have access to.

I tried your suggestion of adding the path in the extra flags section with the -I switch, with mixed success.  I had to turn Deep Search off.  Then there were no compiler errors with finding the #include "filename.h", but there were several errors of undefined references to the functions listed in them.

ex:
Quote:
Remora_SPDC_Sandbox.cpp.o:In function `initCurrentSense()
Remora_SPDC_Sandbox.ino:undefined reference to `readADC(unsigned char const*, unsigned short*, unsigned char)
Remora_SPDC_Sandbox.cpp.o:In function `setup
Remora_SPDC_Sandbox.ino:undefined reference to `initDigIO()
Remora_SPDC_Sandbox.ino:undefined reference to `initMotor()
Remora_SPDC_Sandbox.ino:undefined reference to `wakeMotor()
Remora_SPDC_Sandbox.ino:undefined reference to `initADC()


By the way, this method of manually including .h files and locating them (and their corresponding .c or .cpp files) in the same folder as the sketch works flawlessly in the Arduino IDE.  I don't have to specifically install them as "libraries."  I like this method because it keeps local project-specific files in the local sketch directory, and apart from more general-purpose libraries that may be useful to any sketch or project.
  
Back to top
 
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12076
Location: United Kingdom
Joined: Apr 10th, 2010
Re: Also having trouble with include paths and finding .h files
Reply #3 - Aug 25th, 2016 at 6:42pm
Print Post  
Hi,

Thanks for explaining some more. I think we got diverted with your first report. It sounds kike you reported issues which were a result of your attempt to workaround a simpler issue Smiley

Quote:
By the way, this method of manually including .h files and locating them (and their corresponding .c or .cpp files) in the same folder as the sketch works flawlessly in the Arduino IDE


Okay so Visual Micro should be compatible with the Arduino IDE and we should first make sure you can compile in the Arduino way before attempting to use advanced features such as importing core or using -I compiler switches.

So please remove imported core from your project and physically delete the \src folder from your project.

Remove any compiler switches so we just have a simple Arduino program. (A note here is that I did explain earlier the -I includes will simply include but will not find additional files to compile so it seemed you needed from than an include. It's possible to extend visual micro in many ways but I would prefer not to discuss them while you have problems compiling a basic arduino program.)

Add a .cpp and .h file to the project folder, #include the .h in the .ino code using #include "myfile.h". Then compile and post the error as a .txt file. 

Thanks
« Last Edit: Aug 25th, 2016 at 6:43pm by Tim@Visual Micro »  
Back to top
WWW  
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint