A while back, I created an Arduino plugin for NetBeans so that I could use the full-fledged NetBeans IDE for all my Arduino projects. The approach I took was using the NetBeans project sample module method. Under the hood though, it is nothing more than a makefile and an source file template.

Since the release of Arduino 1.0 a few weeks ago, I have received quite a few inquiries on how to make the plugin work with the new Arduino 1.0. The short answer is you will have to pretty much follow the steps I mentioned to re-create a project sample module with the up-to-date makefile.

Unfortunately, the original makefile (modified from the one by Mellis et al. for Arduino 018) is no longer compatible with the latest 1.0 environment due to the many breaking changes introduced in this new Arduino IDE release.

Anyway, I just updated the makefile to make it work with Arduino 1.0, and you can download it towards the end. The new makefile was tested under Ubuntu 10.04 64bit Linux environment. You will most likely need to make some changes to the makefile for it to work under Windows.

Depending on the installation locations and whether additional libraries are used, you may also need to change the following sections in the makefile:

INSTALL_DIR = $(HOME)/arduino-1.0
#add your specific c modules at the end
#add your specific c++ modules at the end

Here are a few additional changes: the main code file name is changed from main.pde to main.cpp in the project. The original makefile assembles the main.cpp file behind the scene, in the event there is an compilation error the error shown is from the assembled file not main.pde. This behavior could cause some confusion. In this updated makefile, the compilation is done directly against the code file you are working on so it should be slightly more convenient to use. Also, the include directives are consolidated thanks to the latest Arduino IDE changes. If you are using chips other than ATmega328 though, you will need to change the $VARIANTS variable setting to include the correct pins_arduino.h header file:

VARIANTS = $(INSTALL_DIR)/hardware/arduino/variants/standard

Using this makefile, you should be able to configure your favorite IDE (NetBeans, Eclipse, CodeBlocks, KDevelop, etc.) to work with Arduino projects.

You can also download the compiled NetBeans module from below. Just keep in mind that given the nature of this project type, the makefile is static which means you will have to add your own C_MODULES/CXX_MODULES in the makefile if you are using libraries other than those come as default.

The following build targets are available:

all, build, clean, upload


Makefile (for Arduino 1.0, tested under Linux)
NetBeans Plugin for Arduino 1.0 (tested under NetBeans 7.0.1)

Be Sociable, Share!

22 Thoughts on “Makefile for Arduino 1.0”

    • Hey Kwong! I’ve installed succesfuly the netbeans plugin and the make file. But when I open the Main.cpp Netbeans tell me that Arduino.h is not found…how I can fix It???

      • Hi Valmir,

        Arduino.h is located in [arduino instllation dir]/hardware/arduino/cores/arduino
        So you will need to add this to your C compiler’s include directories. (e.g. right click on your project, choose properties and under the build option you will see the include directory option)

        In general, you will need to include the directories that header files are stored.

        • Good evening Kwong! Thanks for fast response…I’ve fixed it…I’ve changed some lines in make file, redirecting the install dir to correct path…and I’ve changed the var MAKEFILE = Makefile to MAKEFILE = makefile…because the makefile name is in lower case…But now I have an error in file Arduino.h in line 212 #include “pins_arduino.h” file not found…probably it’s only a little configuration that I have forgot again…Can you help me?

          • I fixed this! I just included in the assist code the path: [install dir]/hardware/arduino/variants/mega …but I still having problems…rsrsrsrs
            The netbeans error is: nbproject/Makefile-Debug.mk:30: Makefile: File not found

          • Still sounds like a path issue.

            You should not need to have to change the make file. You should be able to set the path information using include paths under C and C++ options. Here is an example that comes from one of my projects:

            C include directories:

            C++ include directories:

            Please let me know if you are able to resolve your issue.

    • Good job Kerry Wong…
      Compiling works like a dream on windows with a few tweaks to the make file, but after creating the hex file, I cant find the ‘Build target upload’. Can You (or someone else) give a little more explanation on that part? What am I missing?

      Tried Matthias’ stuff, but could not compile the static lib, it kept launching make files (about 800 of them when I ended it :( I would like to leave a message at his board, but looks like there no option for it) ).

      • Thanks for your comment. After you compiled your code successfully, use

        make upload

        to invoke avrdude (assuming that avrdude is in your $PATH environment variable. Did you get an error?

        • Thanks for your quick reply.

          Yes i did get an error.

          As said: after right clicking the makefile and choosing: Make target\All the compilation finishes succesfully.
          But when i want to upload, right clicking the make file does not show any upload option.
          By default I get these options right clicking the makefile:
          Make Clean
          Make Target with the options:
          Add Target
          I tried “Add target” at the right click makefile menu and supplied “upload”. Am I doing things correctly by adding the upload entry myself? (couldn’t find an answer for this one)
          The make file configuration part concerning the programmer:
          INSTALL_DIR = E:/00-TOOLS/arduino-1.0.1
          PORT = COM3 #also tried com3, found com3 in the com hardware properties of windows 7 after connecting the UNO
          UPLOAD_RATE = 57600 #also tried 9600
          AVRDUDE_PROGRAMMER = stk500v1 # Also tried it with arduino (found it on the net, however.. no cigar)
          MCU = atmega328p
          F_CPU = 16000000

          ARDUINO = $(INSTALL_DIR)/hardware/arduino/cores/arduino
          VARIANTS = $(INSTALL_DIR)/hardware/arduino/variants/standard
          ARDUINO_LIB = $(INSTALL_DIR)/libraries
          AVR_TOOLS_PATH = E:/00-TOOLS/WinAVR-20100110/bin
          #AVRDUDE_PATH = $(INSTALL_DIR)/hardware/tools
          AVRDUDE_PATH = E:/00-TOOLS/arduino-1.0.1/hardware/tools/avr/bin
          AVRDUDE_CONF_PATH = E:/00-TOOLS/arduino-1.0.1/hardware/tools/avr/etc #added this one for the right location of the configuration file

          Pressing the added upload entry results in the following output with indeed.. an error:

          E:/00-TOOLS/arduino-1.0.1/hardware/tools/avr/bin/avrdude -V -F -C E:/00-TOOLS/arduino-1.0.1/hardware/tools/avr/etc/avrdude.conf -p atmega328p -P com3 -c arduino -b 57600 -D -U flash:w:applet/main.hex
          avrdude: stk500_getsync(): not in sync: resp=0x00

          avrdude done. Thank you.

          make: *** [upload] Error 1

          MAKE FAILED (exit value 2, total time: 12s)

          The arduino UNO RX LED blinks 3 times at the start of the upload, but the arduino apparently doesn’t reply
          (tested the arduino UNO with the arduino IDE 1.0 and 1.0.1 which worked without any problem)

          Any ideas?


          • Thanks for the details.

            First, yes you need to add the “upload” target manually.

            I saw that you were using an Arduino UNO. Since all my testings were done on Duemilanove, I bet that is where the issue lies.

            I believe that the only thing you need to change (take a look in the Makefile) is the upload baud rate, since Uno uses 115200 instead of 57600.

            I don’t have an UNO on hand to test this, but if you could try it out and let me know how it goes that would be great. Thanks.

  • I’ve this error:
    test -d applet || mkdir applet
    /usr/bin /avr-g++ -c -g -Os -w -fno-exceptions -ffunction-sections -fdata-sections -DF_CPU=16000000L -DARDUINO=1.0.5 -I/usr/arduino/hardware/arduino/cores/arduino -I/usr/arduino/hardware/arduino/variants/mega -I/usr/arduino/libraries -mmcu=atmega2560 main.cpp -o applet/main.o
    make: /usr/bin: Permission denied
    make: *** [applet/main.o] Error 1

    BUILD FAILED (exit value 2, total time: 60ms)

    how i can fix this?
    i’m under mac OSX
    I have my build tools (from arduino) here: /Users/aiacos/arduino/hardware/tools/avr/bin
    my makefile:
    # Change this to match your arduino installation directory
    INSTALL_DIR = /usr/arduino
    PORT = /dev/tty.usbmodem*
    UPLOAD_RATE = 115200
    MCU = atmega2560
    F_CPU = 16000000

    ARDUINO = $(INSTALL_DIR)/hardware/arduino/cores/arduino
    VARIANTS = $(INSTALL_DIR)/hardware/arduino/variants/mega
    ARDUINO_LIB = $(INSTALL_DIR)/libraries
    AVR_TOOLS_PATH = /usr/bin #/usr/arduino/hardware/tools/avr/bin/ #/usr/local/CrossPack-AVR-20130212/bin
    AVRDUDE_PATH = $(INSTALL_DIR)/hardware/tools

Leave a Reply

Your email address will not be published. Required fields are marked *