unknown switch: /z__MPLAB_BUILD=1

I’m trying to use MPLAB 8.10 with the 2.40 version of the C18 compiler and friends. I can’t use 3.20 because the Vex code doesn’t compile with it. Everything compiles, but I get stuck on a silly linker error with an unknown switch.

Executing: "C:\MCC18\bin\mplink.exe" /l"C:\mcc18\lib" "18f8520user.lkr" "user_routines_fast.o" "ifi_startup.o" "ifi_utilities.o" "main.o" "printf_lib.o" "user_routines.o" "C:\laptopVex\Vex_alltimers_wauton_jmpr.lib" /z__MPLAB_BUILD=1 /o"VexUserCode.cof"
MPLINK 3.90, LinkerCopyright (c) 2004 Microchip Technology Inc.
Error - unknown switch: /z__MPLAB_BUILD=1
Errors    : 1

I don’t get this error in MPLAB 7.20, but I don’t want to have to install 7.20 because I also need to be able to compile code based on Kevin’s FRC framework. Is there some way I could get rid of this switch? What does it do anyway?

Also, I was reading on the forums that some people compile the code under other IDEs such as Bloodshed or Codeblocks. Is there a way I can compile the code without an IDE altogether, with like a makefile or something? I’m using VIM for editing and I only use MPLAB to click the build button. A plain old command based method would make my day. :stuck_out_tongue:

Um, please forgive me if this is stupid, because I know little about the subject, but why are you even invoking the switch in the first place?

Scanning to the far right of the first line (“Executing…”) the offending switch is there, and since it is not in quotes it’s part of the command line - if you don’t know why it is there, then remove it?

Don.

Uh… MPLAB put it there and… umm… I’m not sure how to remove it. :frowning:

So I guess my question should be, how do I get rid of this switch?

You can check to see if that flag is set by default in MPLAB at:
Project -> Build Options -> Project
Click on the MPLINK Linker tab to see if it’s listed in the global or alternate settings.
If it is there, you can remove it.

Another alternative of course is to run the linker manually from the DOS window without the flag.
A script can run everything for you.

Oh. See, I wasn’t lying about not knowing much…

I might know even less than Don, and I only have MPLAB 7.20, but hey, I’ll take a stab at it. Searching thru the MPLAB Help files, I discovered:

The mcc18.exe compiler uses - command line switches, and mplink uses / command-line switches.

There is also no /z command-line option listed in the help file.

Also, all the switches have a space after the letter. With a space it doesn’t recognize the /z at all.

Dropping into the DOS command line (and getting to the correct subdirectory), I tried the /? (list help) command switch. (It was listed in the help file!) No /z listed there, either.

Google has few listings, half which point to this thread and the other half to another thread with a similar problem, but asking about a different error. It did have this tidbit:

/z__MPLAB_BUILD=1 /z__MPLAB_DEBUG=1

within the command line. It also uses MPLINK 4.15 (not 3.90). Unfortunately the error was for something else, and didn’t get to the /z part at all. But that tidbit might be a clue, that the /z is actually two different switches, /z__MPLAB_BUILD and /z__MPLAB_DEBUG, both which are set to 1.

I did get the error, and as a matter of fact, it’s the same linker:

MPLINK 3.90, Linker
Copyright (c) 2004 Microchip Technology Inc.
Error - unknown switch: /z__MPLAB_BUILD=1
Errors    : 1

(I like to check everything, just to be sure. Now added to the list: If Don says sun rises in east, check to be sure! (sorry Don!) )

Okay, my guess: the /z is for the newer linker, not the 3.90 version. Somehow you are using the older linker with the newer MPLAB, or for an even newer MPLAB. Check to make sure you installed everything.

Second guess: The /z tells the linker to be backward compatable with the older MPLAB’s building and debugging. New linker, but linking older files.

Conclusion: Either upgrade the Linker or remove the /z. Which is what I was thinking you should have tried (once you knew how) to begin with! :cool:

And please, don’t forget to tell us what happened!

Sorry for bringing up a dead topic…but I found a solution

This error is created because you are using MPLAB IDE v. 8.10 with an older MCC18. It thinks that you are using the most recent MCC18. Installing MCC18 4.1 fixes the problem. However, I recall that using this version with the FRC code does not work. Last time I tried (a few months ago) to compile the FRC code with MCC18 4.1, it did not work. So if that is what you are compiling, change the MPLAB that you are using to an older one.

Here’s the Makefile which I use (you will need to modify this):


CC  	= /opt/mcc18-3.10/bin/mcc18.exe
LINKER	= /opt/mcc18-3.10/bin/mplink.exe

# Enable/Disable optimizations with these switches and '+' or '-':
#  -O     all optimizations
#  -Oi    integer promotion
#  -Om    duplicate string merging
#  -On    banking optimizer
#  -Ou    unreachable code removal
#  -Os    code straightening
#  -Ot    tail merging
#  -Ob    branch optimizations
#  -Od    dead code removal
#  -Opa   procedural abstraction
#  -Op    copy propagation
#  -Or    redundant store elimination
#  -Oa    default data in access memory
#  -Ow    WREG tracking

PIC		= 8722
#CFLAGS	= -p=18F$(PIC) -Ou- -Ot- -Ob- -Op- -Or- -Od- -Opa- -nw=2066
CFLAGS	= -p=18F$(PIC) -O+ -nw=2066
INCLUDE	= /i"C:\mcc18-31\h"
INCPATH = /opt/mcc18-3.10/h
DEFS	= -D_FRC_BOARD -D_DEBUG
#DEFS	= -D_FRC_BOARD

LFLAGS	= /w /l"C:\mcc18-31\lib"
LKRFILE	= "18f$(PIC).lkr"
LIBFILE	= "ifi_frc_$(PIC)_30.lib"
FRCCODE	= "Team980"

SOURCES	= \
	autonomous.c \
	disabled.c \
	encoders.c \
	ifi_frc.c \
	imu.c \
	interrupts_ajy.c \
	pid.c \
	pwm.c \
	quick_adc.c \
	robot.c \
	serial_ports.c \
	teleop.c \
	time.c \
	utils.c \

OBJS := $(patsubst %.c, %.o, $(SOURCES))
DEPS := $(patsubst %.o, %.d, $(OBJS))

default : $(FRCCODE).hex

clean :
	$(RM) *.err $(OBJS) $(FRCCODE).hex $(FRCCODE).cod $(FRCCODE).cof $(FRCCODE).lst $(FRCCODE).mcs

%.o : .deps/%.d

.c.o :
	nice gcc -nostdinc -isystem $(INCPATH) -M -MP -D__18F$(PIC) $(DEFS) $< -MF .deps/$*.d
	nice $(CC) $(INCLUDE) $(CFLAGS) $(DEFS) -fo="$@" $<

$(FRCCODE).hex : $(FRCCODE).cof

$(FRCCODE).cof : ${OBJS}
	$(LINKER) $(LFLAGS) $(LKRFILE) $(OBJS) $(FRCLIB) $(LIBFILE) /o"$@"
	@echo *.err

download : ${FRCCODE}.cof
	rigel ${FRCCODE}.hex
	tail -f /dev/ttyS0 | tee running.log

test :
	tail -f /dev/ttyS0 | tee running.log

.deps/%.d : %.c
	gcc -nostdinc -isystem $(INCPATH) -M -MP -D__18F$(PIC) $(DEFS) $< -MF .deps/$*.d

.deps/*:
	@mkdir -p .deps

-include .deps/*

I’m using this under Linux, so I’m using “gcc” to build a dependency list (i.e. so that when you modify a header file, it will recompile, and the list of which header files are included in which .c files is automatically updated). If you don’t have gcc installed, you can pull that functionality out. You may also need to adjust the paths to the compiler and linker; you will certainly need to change the list of source files.