Using Eclipse IDE & makefile as MPLAB replacement

Sorry for the long post, but I hope this is useful to someone who wants to use Eclipse to develop their robot software. It would have helped me.

To configure the open source Eclipse IDE as a replacement for MPLAB on a Windows platform, here are the steps I used:

  • Download and install the Eclipse Platform SDK (3.0 or greater) from This is the basic IDE which is only setup for Java code development.

  • Download and install the Eclipse C/C++ Development Tools (CDT) from Eclipse CDT™ (C/C++ Development Tooling) · GitHub. This is a plug-in that will tailor Eclipse for C code development.

  • Download and install a copy of a “make” utility. I used GNU make that somebody compiled for windows (GNU make for Windows), but you might find other versions. Microsoft’s nmake might also work, but I
    haven’t tried it.

  • Set your “path” environment variable for mpasm, mcc18\bin and gmake. I used: C:\Progra~1\mcc18\mpasm;C:\Progra~1\mcc18\bin;C:\Progra~1\gmake. Note that make sometimes has problems with spaces in path names, so it is best to use the DOS 8.3 alias (i.e. “Progra~1” instead of “Program Files”).

  • Create a file called “makefile” in the folder with your C source code. You can tailor the one below (also attached) to your liking. Be sure to replace multiple spaces at the beginning of lines with <tabs> if you cut and paste. A make manual is located at: GNU make

  • Verify your makefile is working well from a DOS command prompt by trying “make clean” and “make all” commands.

  • Start Eclipse and create a new Standard Make C Project and select options as follows:

    • Fill in project name and uncheck the “Use default” box to set the directory to point to your robot code.
    • The defaults on the Make Builder tab should be fine
    • On the Error Parsers tab, only the CDT GNU C/C++ Error Parser box should be checked.
  • Try a Project > Clean and a Project > Build All commands and see if your code builds properly. Any code errors should show up in the Problems tab of the console window and you can click on an error and be taken to that point in the code just like in MPLAB. If you have makefile problems, you can edit it from within Eclipse.

That’s it. I know everybody has their favorite IDE, but for those who like Eclipse, this will give you all the functionality of MPLAB with the exception of the simulator.

Good luck.

Jeff Holland
Software Mentor / Volunteer

#************** Example Makefile ***********************


Manual makefile to go with Eclipse

NOTE: enviornment variables must be set to find linker & compiler.

NOTE: runs with GNU Make. Might also run with Microsoft nmake

with tweaks.

This Makefile will compile any .c file in the current directory and link the

objects into a .hex file to load into the robot.

Rename this file “makefile” and put in your C source code folder.

The OBJFILES variable is filled with .o targets using the wildcard

command and patsubst. The $(wildcard *.c) will retrieve any .c

file in the current directory and store it in a variable. The patsubstr

functions is used to convert a file from one format to another. In

this case each .c file is converted into a .o extension and then

stored into OBJFILES. This variable is then used to compile each .c file.

The rule %.o: %.c rebuilds any .o file if the cooresponding .c file has


In the compile line you will see two variables @ and <.

@ will match the target and the < will match the dependency. So, for

example, &lt; will contain main.c whenever @ contains main.o.

Note: makefiles are counterintuitive in that the rules don’t run in the order

listed in the file, but instead run whenever they are matched.

Also be careful with tabs and spaces. Rules need a tab (not spaces)

before each action.


#del for windows, rm for unix
RM := del /F


LINKER = mplink

CC = mcc18


CFLAGS = -i"C:PROGRA~1\mcc18\h" -nw=2066


optimization parameters (default = full optimization)
OPT_DEBUG=-Ou- -Ot- -Ob- -Op- -Or- -Od- -Opa-

make a list of object files that match all C files
OBJFILES := (patsubst %.c,%.o,(wildcard *.c))


all: $(PROJECT).hex

#re-link if any object file changed
(LINKER) "18f8520user.lkr" (OBJFILES) “FRC_library.lib” /l (LIB_PATH) /m (PROJECT).map /o $(PROJECT).hex

Recompile a file if it’s c-file changes,

OR recompile everything if ANY header file changes

%.o: %.c *.h

#delete all the build files so you can start from scratch.
-(RM) (PROJECT).hex
-(RM) (PROJECT).map
-(RM) (PROJECT).lst
-(RM) (PROJECT).cod

Example_makefile.txt (2.4 KB)

Example_makefile.txt (2.4 KB)