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] 2  Send TopicPrint
Hot Topic (More than 8 Replies) Visual Micro Arduino Command Line Interface failes to build Project from command line (Read 7421 times)
stm
Junior Member
**
Offline


Posts: 27
Joined: Jul 5th, 2018
Visual Micro Arduino Command Line Interface failes to build Project from command line
Sep 2nd, 2019 at 12:09pm
Print Post  
I am trying to automate a build of a project using your Command Line Interface tool (https://www.visualmicro.com/page/Visual-Micro-Command-Line-Interface.aspx). ;

The project builds from within Visual Studio but the build fails from the command line. Already the first header file that is used from one of our own libraries is not found and the build fails.

To me it looks like the "AdditionalIncludeDirectories" property of the project file is not respected when using the Command Line Interface. Also the additional defines don't seem to be used for the CLI build.

The AdditionalIncludeDirectories property from the project .vcxproj file looks as follows:

Code
Select All
 <PropertyGroup />
  <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
    <ClCompile>
      <WarningLevel>Level3</WarningLevel>
      <Optimization>Disabled</Optimization>
      <SDLCheck>true</SDLCheck>
     ..\libraries\MinionSanityCheck\src; ...
 ... 



Attachment 1: Failing build log of CLI
Attachment 2: Working build log of Visual Studio

Let me know if you need more details of anything. Thank you.
« Last Edit: Sep 2nd, 2019 at 12:25pm by stm »  

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


Posts: 12071
Location: United Kingdom
Joined: Apr 10th, 2010
Re: Visual Micro Arduino Command Line Interface failes to build Project from command line
Reply #1 - Oct 12th, 2019 at 1:37pm
Print Post  
Sorry this took so long. The command line tool has been updated.

Visual Micro Command Line Tool
  
Back to top
WWW  
IP Logged
 
stm
Junior Member
**
Offline


Posts: 27
Joined: Jul 5th, 2018
Re: Visual Micro Arduino Command Line Interface failes to build Project from command line
Reply #2 - Oct 14th, 2019 at 2:11pm
Print Post  
Hello Tim
Just tried the new version and unfortunately the issue has not been resolved from what I see. All entries in AdditionalIncludeDirectories are still not considered. The build log shows many -IC entries but none of them coming from the .vcxproj project file. the build log looks the same as above and shows the same error messages so I pass on attaching them again.
  
Back to top
 
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12071
Location: United Kingdom
Joined: Apr 10th, 2010
Re: Visual Micro Arduino Command Line Interface failes to build Project from command line
Reply #3 - Oct 14th, 2019 at 2:37pm
Print Post  
Hi

Sorry I didn't fully read your intiial post. There was an issue with the command line tool which is now fixed however your report about include directories is unrelated.

The additiona include directories in the project settings should be considered read-only for intellisense only.

You can specify additional compiler includes using the extra flags F4 project properties. Use the -IdirName syntax.

Switching on the build properties on the vMicro compiler menu will also allow you to see all the build variables which can also be used when specifying include paths. For example, if there is a project_path variable it can be used like so:-

-I{project_path}\..\myHeaders -I{project_path}\..\myHeaders2 


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


Posts: 12071
Location: United Kingdom
Joined: Apr 10th, 2010
Re: Visual Micro Arduino Command Line Interface failes to build Project from command line
Reply #4 - Oct 19th, 2019 at 2:35pm
Print Post  
Once again appologies for the delay and thanks for providing such useful info in the outputs.

The issue is some confusion that we will clarify in the documentation and also provide better feed back in the CLI.

As stated previously the include paths are not stored in VS, in fact they are dynamically recreated each time a project changes or builds. That is for Vs intellisense.

In Arduino paths are generally worked out dynamically and in this case what is missing is the Arduino Sketch Book folder location. We can see the sketch book location easly in the IDE build output but it is missing from your CLI build output.

For Arduino, the user installed libraries are always assumed to be in "SketchBook\Libraries" which the CLI can't see. This is why you believed include paths are missing.

The reason the CLI can not see the sketchbook is that your CI command does not specify an IDEName (-builder.application_id=) therefore Visual Micro will use the NoIDE option (that you can see in the VsIDE).

In the VsIDE you have specified a Sketch Book folder location of "Public/Arduino/ArduinoGIT" for the "Arduino 1.6/1.8" application but have not set a Sketch Book folder location for the NoIDE application. Hence an unknown Sketch Book location will probably default to "myDocuments\Arduino" where your \libraries do not exist.

1 - NoIDE

Code
Select All
vmbuild.exe  -builder.ide_path="D:\Arduino\arduino-1.8.1" -builder.upload=false -builder.build=true "  -builder.verbose=true -builder.verbose_warnings=true -builder.board_id=Pico  



2 - Arduino 1.6/1.8 IDE

Code
Select All
vmbuild.exe -builder.application_id=arduino16x -builder.upload=false -builder.build=true "  -builder.verbose=true -builder.verbose_warnings=true -builder.board_id=Pico  



Solution

Therefore the solution is to either add the optional Sketch Book Location to the NoIDE option in Visual Micro or use the 2nd command syntax example above.

I hope this makes sense?
« Last Edit: Oct 19th, 2019 at 2:36pm by Tim@Visual Micro »  
Back to top
WWW  
IP Logged
 
stm
Junior Member
**
Offline


Posts: 27
Joined: Jul 5th, 2018
Re: Visual Micro Arduino Command Line Interface failes to build Project from command line
Reply #5 - Nov 6th, 2019 at 12:28pm
Print Post  
Hello Tim

Thanks for your last message: That really helped to proceed. Two issues remain:

1) small issue: VM_ADDITIONAL_PREPROG from the .vcxproj seem to be ignored -> would be nice if this was also taken this into account

2) Now there are errors during the linking. Please see the attached log. What did we forget?
  

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


Posts: 12071
Location: United Kingdom
Joined: Apr 10th, 2010
Re: Visual Micro Arduino Command Line Interface failes to build Project from command line
Reply #6 - Nov 6th, 2019 at 1:33pm
Print Post  
Yes we will add the additonal_preprog to the cli over the next week or so.

For the linker error we might need the source of a simple example with the problem. One thing is to make sure you do not have any unwanted source code files in the poroject folder. regardless of what you see in the solution explorer vm will compile all files in the project folder (default setting) because the arduino ide will do the same.

  
Back to top
WWW  
IP Logged
 
stm
Junior Member
**
Offline


Posts: 27
Joined: Jul 5th, 2018
Re: Visual Micro Arduino Command Line Interface failes to build Project from command line
Reply #7 - Nov 6th, 2019 at 4:52pm
Print Post  
Hello again

1) Great news!

2) I attached a simple example project. The command to build it: 

VMBuild.exe -builder.application_id=arduino16x -builder.upload=false -builder.build=true io\example\MinionGpioReadWriteExample\MinionGpioReadWriteExample.vcxproj" -builder.verbose=true -builder.verbose_warnings=true -builder.board_id=Pico onGpio\example\MinionGpioReadWriteExample\build"
  

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


Posts: 12071
Location: United Kingdom
Joined: Apr 10th, 2010
Re: Visual Micro Arduino Command Line Interface failes to build Project from command line
Reply #8 - Nov 6th, 2019 at 6:52pm
Print Post  
Hi,

Before using the cli we need to ensure the project builds in VS first. I guess it failed?

One issue with the linker is that the use of TwoWire is incorrect. I changed it to the following so that it links.

Code (C++)
Select All
//vm edited will not work but will compile
TwoWire  Wire2 = TwoWire(&sercom3, 20, 21);
MinionI2cBus _i2c(Wire2, _i2cBus, SDA, SCL);
 



There might also be some confusion when attempting to use a normal arduino project below an arduino library. The link below shows a a solution with your project outside of the libs area. We will investigate this some more but the solution above works.

I might be wrong but if I recall arduino libs with library properties have the code in a folder called \src. This is the arduino v2 lib format. You will see that I moved the lib code to src folders. v1 format is supported but it's not very expandable due to limitiations of library sub folder.

I side note that if you move libraries that are referenced as shared libraries the main project might not open. This is a VS quirk but you can edit the vcxproj file with a text editor and remove or correct the shared lib reference paths.

This project builds okay for me although you might want to change your project and make correction to TwoWire init.

https://1drv.ms/u/s!AsT00oFsGAmRoKZjdw7X78evwOMpDA?e=gtieFr

It's possible you original config would work okay if you set the arduino sketch book path as you did. However when using shared projects you can leave sketch book as default so that any downloaded libraries stay outside of your code base. It's a preference.
« Last Edit: Nov 6th, 2019 at 8:29pm by Tim@Visual Micro »  
Back to top
WWW  
IP Logged
 
stm
Junior Member
**
Offline


Posts: 27
Joined: Jul 5th, 2018
Re: Visual Micro Arduino Command Line Interface failes to build Project from command line
Reply #9 - Nov 11th, 2019 at 10:49am
Print Post  
Hello Tim

TwoWire was no issue for us and of course the projects were building fine in VisualStudio but not using the CLI tool. The issues in this thread could only be seen in the CLI tool. After playing around a lot, we found that the following two points really helped to make it build in the CLI tool as well:

1) We indeed had to follow the convention of v2 and put user library code in a folder named "src"
2) Also for projects created a few months ago (can't recall exactly how, maybe using VM toolset?), we had to create new projects from scratch and then copy over the code. Then the errors dissapeared and the projects could also be built using the CLI tool.

I think we made real progress towards building projects using scripts. Thanks for your help and we are looking forward to the new version of the CLI that supports additonal_preprog!
  
Back to top
 
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12071
Location: United Kingdom
Joined: Apr 10th, 2010
Re: Visual Micro Arduino Command Line Interface failes to build Project from command line
Reply #10 - Nov 11th, 2019 at 3:01pm
Print Post  
Thanks, yes it won't be long for the next cli release.
  
Back to top
WWW  
IP Logged
 
stm
Junior Member
**
Offline


Posts: 27
Joined: Jul 5th, 2018
Re: Visual Micro Arduino Command Line Interface failes to build Project from command line
Reply #11 - Nov 11th, 2019 at 6:13pm
Print Post  
One thing that we noticed was that one has to provide an absolute output path. If a relative path is specified then the output goes to some buried folder in AppData (see example below). I don't know if this is by design but from my point of view it would be better to be able to output to a relative path from the working directory path.


Example for -builder.output_directory=".build/publish/example.application" :

End
# Copy build result to 'Project>Property Pages>Intermediate Directory'
# Destination: /Release/.build/publish/example.application
  
Back to top
 
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12071
Location: United Kingdom
Joined: Apr 10th, 2010
Re: Visual Micro Arduino Command Line Interface failes to build Project from command line
Reply #12 - Nov 12th, 2019 at 1:12pm
Print Post  
Yes will do thanks
  
Back to top
WWW  
IP Logged
 
stm
Junior Member
**
Offline


Posts: 27
Joined: Jul 5th, 2018
Re: Visual Micro Arduino Command Line Interface failes to build Project from command line
Reply #13 - Nov 15th, 2019 at 7:36am
Print Post  
Me again.. I have another important factor that breaks the build when using the CLI instead of Visual Studio:

When adding user libraries to a solution and adding references to the project, the CLI fails to build:

<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Label="Shared">
<Import Project="..\libraries\MinionLogging\MinionLogging.vcxitems" Label="Shared" />
<Import Project="..\libraries\BldcDriver\BldcDriver.vcxitems" Label="Shared" />
</ImportGroup>
...

When removing those references, the CLI builds just fine:

<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Label="Shared" />
...

My motivation to add user libraries to the solution and references to the project is that one can work on the libraries better and Intellisense works fine that way.

Is this a bug in the CLI or am I doing something wrong?
« Last Edit: Nov 15th, 2019 at 7:37am by stm »  
Back to top
 
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12071
Location: United Kingdom
Joined: Apr 10th, 2010
Re: Visual Micro Arduino Command Line Interface failes to build Project from command line
Reply #14 - Nov 16th, 2019 at 11:00pm
Print Post  
The VMBuild.exe tool has been updated. Thanks the feedback. 

Command Line Tool for Visual Studio projects

nb: Because of the error you encountered previously, you might find a "Build>Clean Solution" in Visual Studio is required before first use of the CLI for the failed project. If the last build was a VS build then that should not be required.


  
Back to top
WWW  
IP Logged
 
stm
Junior Member
**
Offline


Posts: 27
Joined: Jul 5th, 2018
Re: Visual Micro Arduino Command Line Interface failes to build Project from command line
Reply #15 - Nov 19th, 2019 at 7:26pm
Print Post  
Thanks.. it looks very good for the automated build now!! 

One issue is left (probably the last one as it looks): I moved the working build setup to a BuildAgent (TeamCity) and tried to automate the build from there. It fails with "An error was encountered during the 'Deep Search' library discovery process." It does not find the header file of the first included library. I know that TeamCity sets some Environment Variables like for instance the TEMP directory. Do you rely on any environment paths to be fixed (maybe hardcoded somewhere in your code)? If so it would be great to be able to override those by a parameter.
  
Back to top
 
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12071
Location: United Kingdom
Joined: Apr 10th, 2010
Re: Visual Micro Arduino Command Line Interface failes to build Project from command line
Reply #16 - Nov 19th, 2019 at 7:32pm
Print Post  
The temp build folders are shown in the output. We need to see the verbose error to see what is a problem. 

Possibly it can't see your users\name\appdata\local\arduino15 folder in which case move the contents to a folder below the arduino ide called portable.
« Last Edit: Nov 19th, 2019 at 7:35pm by Tim@Visual Micro »  
Back to top
WWW  
IP Logged
 
stm
Junior Member
**
Offline


Posts: 27
Joined: Jul 5th, 2018
Re: Visual Micro Arduino Command Line Interface failes to build Project from command line
Reply #17 - Nov 19th, 2019 at 7:48pm
Print Post  
I know it's really strange as everything else works now. That's why was hoping for a simple explanation (hardcoded path or similar). Please find the two logs attached. Once directly from script and once running the same script in the BuildAgent TeamCity context (both on same hardware). 

Please note the additional include of "libraries\ezTime\src" in the working case:
« Last Edit: Nov 19th, 2019 at 7:50pm by stm »  

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


Posts: 12071
Location: United Kingdom
Joined: Apr 10th, 2010
Re: Visual Micro Arduino Command Line Interface failes to build Project from command line
Reply #18 - Nov 19th, 2019 at 7:55pm
Print Post  
I need to see the full build when it works because that shows what was discovered by deep search. I suspect a library issue.

This is the error you see when it fails. exTime.h is not part of the project code so we need to look at libraries.

I suggest adding "-builder.dump_props=true" to the CLI

[code : fatal error: ezTime.h: No such file or directory [/code]
« Last Edit: Nov 19th, 2019 at 8:00pm by Tim@Visual Micro »  
Back to top
WWW  
IP Logged
 
stm
Junior Member
**
Offline


Posts: 27
Joined: Jul 5th, 2018
Re: Visual Micro Arduino Command Line Interface failes to build Project from command line
Reply #19 - Nov 19th, 2019 at 11:40pm
Print Post  
Your hint with -builder.dump_props=true argument showed that the only difference is that in the failing case of the BuildAgent (automated build using TeamCity) the sketchbook location is not the custom defined one but the default one which is probably the issue:

location.sketchbook=C:\Users\buildadmin\Documents\Arduino

Where does VMBuilder get this path from meaning from where should the custom path be read out?

AMEND: I could just add "-location.sketchbook=<custom_sketchbook_path>" as a build argument and that was accepted and also shown correctly in the dump_props lists. But it did not change the fact that deep search failed at the very beginning.

« Last Edit: Nov 20th, 2019 at 12:01am by stm »  
Back to top
 
IP Logged
 
Page Index Toggle Pages: [1] 2 
Send TopicPrint