Log in

View Full Version : Visual Studio C18/MPLINK build rules >>>HERE<<<


itsnotabigtruck
17-01-2008, 19:17
I got tired of having to use MPLAB, and didn't want to install Eclipse (already had VS), so I wrote this build rules file in order to use VC to compile for the IFI RC.

This is very, very beta, and I am not responsible if it fries your robot, fries your computer, kills your dog, burns your house, etc.

Visual Studio MCC18 build rules file (http://fastmemo.home.comcast.net/downloads/mcc18.rules) (right-click and choose Save Link As to download)

In order to use this:


Create a Visual C++ project, preferably close to the root of the drive.
Put mcc18.rules in your project directory
Right-click the project in Solution Explorer and select Custom Build Rules
Click Find Existing and find the mcc18.rules you put in the project directory
Click No if you get asked whether you want to add the directory you chose to the build rules search path
Click OK
Right-click the project again and select Tool Build Order
Check Microchip C18 C Compiler and Microchip MPLINK Linker, and uncheck everything else
Click OK
Right-click the project again and select Properties
Select Microchip C18 C Compiler, then General
Set these options:

Compiler Memory Model: Large
Target Processor: 18F8722
Additional Macros: _DONT_USE_TMR0;_LARGE_CODE;_FRC_BOARD
Suppress Warnings: 2066

Then go to Optimization, and set more options (note that you probably don't need to turn off all of these optimizations, they're just the settings from the default code):

Disable Unreachable Code Removal: Yes (-Ou-)
Disable Tail Merging: Yes (-Ot-)
Disable Branch Optimization: Yes (-Ob-)
Disable Dead Code Removal: Yes (-Od-)
Disable Procedural Abstraction: Yes (-Opa-)
Disable Copy Propagation: Yes (-Op-)
Disable Redundant Store Elimination: Yes (-Or-)

You might also want to set Default Char Unsigned to Yes (-k)
Now go to Microchip MPLINK Linker and set these options:

Linker Script Search Path: $(ProjectDir) (in most cases)
Output HEX File Type: INHX32
Suppress .COD and .LST File Creation: Yes (/w)
Additional Input Files: 18F8722.lkr (if you're using the default IFI linker script)

Now go to General under Configuration Properties
Set Output Directory to Debug\bin (or somewhere else, if you prefer)
Set Intermediate Directory to Debug\obj (or somewhere else, if you prefer)
Set Extensions to Delete on Clean to "$(IntDir)\*;$(OutDir)\*.out;$(OutDir)\*.hex;$(OutD ir)\*.hxh;$(OutDir)\*.hxl;*.o" (no quotes)
Set Configuration Type to Utility
Click OK
Copy all your code to the project folder
Click the Show All Files button in Solution Explorer
Select all your headers, C files, object libraries, and linker scripts (note: only include libraries and linker scripts for the 8722)
Right-click them and select Include in Project
Hit F6
You're done!

EHaskins
17-01-2008, 21:01
Sweet!

I haven't had a chance to test it, but I will.

TheGouger
19-01-2008, 15:36
Good job. I have VS 2008 and it compiles with no problems. I haven't had the chance to test it on our robot, but I'll be able to do that sometime next week (I doubt there will be any significant problems :cool:)

itsnotabigtruck
25-01-2008, 01:22
Here's an updated toolchain, which now includes a C# program which regexes the C18 output in order to make the error list work. Yay!

NEW TOOLCHAIN WITH ERROR FORMATTER (http://fastmemo.home.comcast.net/downloads/vschainwerrlist.zip)

Note that this doesn't work with linker errors or warning level 3 messages (default is level 2).

Source is included; pls. upload if you improve it.

Heffo
03-03-2008, 07:48
Hello,

Thanks for posting the information on how to use C18 from inside Visual Studio. I really hate the interface in MPLAB and love Visual Studio.

I have my *.c files compiling properly, generating the object files, but for some reason, the linker isn't being started to build the hex file. Do you have any suggestions as to what may be the issue.

I am using Visual Studio 2005 Professional.

Regards,
Robert Heffernan