Windows command line build

by CosineKitty (slight modifications for 0011 by raptorofaxys)

The command line build provided by Arduino is not very Windows friendly: you have to figure out how to get cygwin working, install a make utility, grep, and other Unix utilities. Here is an alternative for Windows 2000 or Windows XP. (These batch files will not work with versions earlier than Windows 2000 because they rely on advanced batch file features.)

Problems? Bugs?

Please report any problems you have with these batch files in the following forum topic:;start=all


Download the following 3 batch files to somewhere in your search path.

Latest batch file update: September 10, 2008.

After downloading, you will need to rename abuild.txt to abuild.bat, aupload.txt to aupload.bat, and agetpref.txt to agetpref.bat. (This wiki does not allow attachment of batch files!)

You will need to set the following few environment variables. (To create environment variables, go into Start / Control Panel / System. Click on the Advanced tab. Press the button that says Environment Variables. In the User Variables pane, click the New button. You must close and re-open any command prompt windows before the new variable takes effect; otherwise the batch files here will not work.)

Variable NameVariable Value
ARDUINO_PATHwhere you installed Arduino on your computer (e.g. C:\ARDUINO-0011)
ARDUINO_MCUthe name of your microcontroller (e.g., atmega168)
ARDUINO_PROGRAMMERthe name of the programmer you wish to use (usually stk500)
ARDUINO_FCPUthe clock frequency of your microcontroller (usually 16000000 for atmega168)
ARDUINO_COMPORTthe port to which your programmer is connected (e.g. COM1, COM2, etc.)
ARDUINO_BURNRATEthe baud rate at which the download is to occur (19200 seems to be a good starting point)


The batch file aupload.bat is used to upload a sketch once you have compiled and linked it. Note that abuild.bat calls aupload.bat after compiling and linking (unless you specify the -c option), so you may not need to manually run aupload.bat unless you are doing something unusual. You just need aupload.bat somewhere in your search path. If you are curious, run aupload.bat with no command line parameters for help.


Run this batch file with no command line parameters for help.

You can use abuild.bat to build and upload your sketch (with .pde extension), or a raw C++ file (with .cpp extension). If the file has a .cpp extension, no preprocessing will be done; the code will be compiled as-is using avr-g++. If the file has a .pde extension, some minor preprocessing will be applied, though not as much as the Arduino IDE does.

This means you may need to modify your .pde file to have function prototypes at the front of the file. For example, if you have functions like:

    void MyHappyFunction (int x, char *s)
        // ... blah blah blah ...

    int AnotherHappyFunction (int fred, int barney)
        // ... more stuff ...

you will need to copy function prototypes to the front of the file like this:

    #ifdef ABUILD_BATCH
        void MyHappyFunction (int x, char *s);
        int AnotherHappyFunction (int fred, int barney);
    #endif // ABUILD_BATCH

This will get rid of compiler errors saying that you are calling an undefined function, if one function calls another that has not yet been defined yet in the code.

Note that abuild.bat compiles your code with the symbol ABUILD_BATCH defined equal to 1, so that you can use conditional compilation to make your code work with both the Arduino IDE and abuild.bat.

By default, abuild.bat will attempt to pull in the required include paths and object files for any external libraries you have installed. To disable this behaviour, use the -n command-line option.

Note that abuild.bat will call aupload.bat to upload your sketch, unless you specify the -c option.


The batch file agetpref.bat is a utility that both abuild.bat and aupload.bat use to extract the right environment variables. Do not run this batch file; just put it where the other two batch files can find it!

Older Versions of the Batch Files

Judging by the forum, these files worked with 0007, but broken when the Arduino environment changed some time thereafter. They are the original files provided by Don Cross.