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
Visual Micro Arduino Command Line Interface failes to build Project from command line (Read 495 times)
stm
Newbies
*
Offline



Posts: 6
Visual Micro Arduino Command Line Interface failes to build Project from command line
Sep 2nd, 2019 at 1:09pm
 
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:
 <PropertyGroup />
  <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
    <ClCompile>
      <WarningLevel>Level3</WarningLevel>
      <Optimization>Disabled</Optimization>
      <SDLCheck>true</SDLCheck>
      <AdditionalIncludeDirectories>$(ProjectDir)..\RunningTargetMotor;$(ProjectDir)..\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.
Back to top
« Last Edit: Sep 2nd, 2019 at 1:25pm by stm »  
 
IP Logged
 
Visual Micro
Administrator
*****
Offline



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

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



Posts: 6
Re: Visual Micro Arduino Command Line Interface failes to build Project from command line
Reply #2 - Oct 14th, 2019 at 3:11pm
 
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
 
Visual Micro
Administrator
*****
Offline



Posts: 10529
United Kingdom
Re: Visual Micro Arduino Command Line Interface failes to build Project from command line
Reply #3 - Oct 14th, 2019 at 3:37pm
 
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
 
Visual Micro
Administrator
*****
Offline



Posts: 10529
United Kingdom
Re: Visual Micro Arduino Command Line Interface failes to build Project from command line
Reply #4 - Oct 19th, 2019 at 3:35pm
 
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:
vmbuild.exe  -builder.ide_path="D:\Arduino\arduino-1.8.1" -builder.upload=false -builder.build=true -builder.project_path="C:\Users\tl\Documents\Arduino\MyProject\MyProject.vcxproj"  -builder.verbose=true -builder.verbose_warnings=true -builder.board_id=Pico  



2 - Arduino 1.6/1.8 IDE

Code:
vmbuild.exe -builder.application_id=arduino16x -builder.upload=false -builder.build=true -builder.project_path="C:\Users\tl\Documents\Arduino\MyProject\MyProject.vcxproj"  -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?
Back to top
« Last Edit: Oct 19th, 2019 at 3:36pm by Visual Micro »  
WWW  
IP Logged
 
stm
Newbies
*
Offline



Posts: 6
Re: Visual Micro Arduino Command Line Interface failes to build Project from command line
Reply #5 - Nov 6th, 2019 at 12:28pm
 
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?
Back to top
 
 
IP Logged
 
Visual Micro
Administrator
*****
Offline



Posts: 10529
United Kingdom
Re: Visual Micro Arduino Command Line Interface failes to build Project from command line
Reply #6 - Nov 6th, 2019 at 1:33pm
 
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
Newbies
*
Offline



Posts: 6
Re: Visual Micro Arduino Command Line Interface failes to build Project from command line
Reply #7 - Nov 6th, 2019 at 4:52pm
 
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 -builder.project_path="C:\Users\Public\arduino\ExampleProject\libraries\MinionGp
io\example\MinionGpioReadWriteExample\MinionGpioReadWriteExample.vcxproj" -builder.verbose=true -builder.verbose_warnings=true -builder.board_id=Pico -builder.output_directory="C:\Users\Public\arduino\ExampleProject\libraries\Mini
onGpio\example\MinionGpioReadWriteExample\build"
Back to top
 
 
IP Logged
 
Visual Micro
Administrator
*****
Offline



Posts: 10529
United Kingdom
Re: Visual Micro Arduino Command Line Interface failes to build Project from command line
Reply #8 - Nov 6th, 2019 at 6:52pm
 
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++):
//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.
Back to top
« Last Edit: Nov 6th, 2019 at 8:29pm by Visual Micro »  
WWW  
IP Logged
 
stm
Newbies
*
Offline



Posts: 6
Re: Visual Micro Arduino Command Line Interface failes to build Project from command line
Reply #9 - Nov 11th, 2019 at 10:49am
 
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
 
Visual Micro
Administrator
*****
Offline



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



Posts: 6
Re: Visual Micro Arduino Command Line Interface failes to build Project from command line
Reply #11 - Nov 11th, 2019 at 6:13pm
 
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: file:///C:/Users/stm/AppData/Local/Temp/VMBuilds/ExampleProject/espressif_pico32
/Release/.build/publish/example.application
Back to top
 
 
IP Logged
 
Visual Micro
Administrator
*****
Offline



Posts: 10529
United Kingdom
Re: Visual Micro Arduino Command Line Interface failes to build Project from command line
Reply #12 - Yesterday at 1:12pm
 
Yes will do thanks
Back to top
 
WWW  
IP Logged
 
Page Index Toggle Pages: 1
Send Topic Print