Code::Blocks IDE interface (Tutorial/Makefile)


After having a lot of problems with the interface in MPLAB, I decided to find a way to use my choice IDE of Code::Blocks to program the RC. After many searches and problems, I’ve managed to create a very nice interface for programming it.
Code::Blocks is a lightweight, opensource editor written in C++ with the wxWidgets toolkit. It’s available for any operating system wxWidgets supports, although you’re still tied to windows for the MPLAB C18 Compiler. It can be found at
My setup uses a custom makefile based on one I’ve had from long ago, originally written for Eclipse. I’m not sure of the author, but I cannot take full credit for it. However, I have customized it for use with Code::Blocks to take advantage of a really cool feature: Using the drop-down box in the IDE, you can change code between the 18F8722 and 18F8520 processor. It automatically switches out all libraries and build options. You can, in fact, compile it for one and then the other, without running a clean or anything. It will also keep the HEX output files named according to processor. Probably handy for when you need to run something on both models.

To use this setup, the MPLAB C18 compiler must be installed with the PATH environment variable pointing to the compiler’s directory. Also, Code::Blocks must be installed, of course. I’ve only tested this with the 1.0rc2 on the main website.
The instructions for using this interface are as follows:

  1. Download the makefile on my website and save it in the same directory as your code. After you’ve put the makefile in there, create two new folders: “obj.8722” and “obj.8520”. Also, rename the libraries for the 8722 PIC to FRC_Library_8722.lib, and the library for the 8520 to FRC_Library_8520.lib.
  2. Create a new Code::Blocks project, add all of your *.c and *.h files to it, and save the project in the same place as your code
  3. In your project, add the 2 build targets PIC18F8722 and PIC18F8520. You can do this by clicking Project->Properties on the menu bar and clicking the “Targets” tab.
  4. Now, leaving that dialog open, click the “Project” tab. Check the box that says “This is a custom Makefile” and make sure the makefile name matches the name of the makefile (“Makefile”)
  5. Click OK to close the window
  6. Click Build->Options on the menu bar. Go to the “Other” tab, and click the drop-down box labeled “Build Method”. Select “Work with Makefiles (GNU make is required)”.
  7. Click OK to close the window
  8. On the drop-down box on the toolbar of the editor, labeled “Build target”, select your processor of choice
  9. Click “Build” either via the “Build” menu or the shortcut button on the toolbar.
  10. Done! Just use the IFI_Loader applicatoin to download either PIC18F8722.hex or PIC18F8520.hex to your robot controller.

(Note: The makefile also defaults to having the MPLAB C18 compiler include directory and library directory in “c:\mcc18\h” and “c:\mcc18\lib”. If this isn’t what you want, open the makefile with notepad and look at the top 5-ish lines, and change what you need. MPDRIVE changes the hard drive/partition you have it installed on, which is default to C)

If you’ve got any questions, comments, etc. let me know. If this has been discussed already, I apologize, as a quick forum search didn’t come up with it for me when I needed it.

I’ve tested this only with the “make” utility included with Code::Blocks. If you run into errors, make sure that A) you installed Code::Blocks with the compiler it comes with, and B) You have that compiler selected as default. That way it will use the version of GNU make included with Code::Blocks.

I take it I have to have gcc installed?

It auto-detected the gcc install that came with Bloodshed Dev-C++ and was using the mingw32-make.exe from there, but I still kept getting the error:

mingw32-make.exe: *** No rule to make target `obj.8722\cal.o', needed by `PIC18F8722.hex'.  Stop.
Process terminated with status 1 (0 minutes, 0 seconds)
0 errors, 0 warnings

I’m not sure what this means. I’m going to check everything over again, but I doubt I am going to get it myself because I’m a n00b…:o


EDIT: It seems to be looking for the compiler chosen in the dropdown box. I can’t find a way to override this and it seems that…HOLD on a SEC! I think I just answered my own question…

EDIT AGAIN: What do I set for the Make: path for the compiler settings? It doesn’t look like C18 even has make packaged with it…

EDIT AGAIN AGAIN: Now I got it to run mcc18 at least, but now it gave me something like 30 errors…I’m starting to give up…

I think I was able to get it to work. I tried copying all of the *.o files into the obj.8722 folder. Then renamed FRC_Library.lib to FRC_Library_8722.lib. There were no error messages, and it created the hex file.

I left the complier settings to its gcc defaults.

If you could post the errors, I’d be glad to help out. Also, CmptrGk, thanks, I’ll add the name change into the directions above.

Yeah, being the nerd I am I should know better than to say “an error popped up” but not specify what error…

I attached a screenshot because I couldn’t copy/paste them and I’m not about to re-type them. My guess is that for some reason it is using the mingw gcc that I have installed somewhere else. I need to uninstall it and try again, but at the moment I’m too lazy…




Give me until the end of the weekend and I’ll put the default code and a Code::Blocks project in a zip file for easy access, if anyone’s interested. I personally find the interface much easier to use. Also, on the laptop we use, it produces no errors on opening :-).

@JBotAlan: To me it looks like a different version of the compiler or something. If it gets to the point of compiling and then does that, I’m not sure what’s going on. v2.4?

I see someone else is using Code::Blocks
A few months ago I put up Code::Blocks project that didn’t rely on make.exe and didn’t use makefiles, it was for RC2 but I’m currently using one that works with the snapshot versions and it works very well, I used it during last seasons.
I attached the file here

But the zip file didn’t work in winrar, someone else posted a fixed version of the zip file I believe

I also put how to call the mcc18.exe and mplink.exe which might help with some problems

I have searched all over the web, this site, and everywhere.

Does anyone have the makefile that will work with Code Blocks? I’m not exactly sure how the IDE passes targets and I can’t get it to work.


You may want to check out JonathanLKS’ latest post over here: