我正在尝试使用 XC8 编译器编译和链接 C 程序。我从 C18 编译器进行了更改,并对代码进行了一些小的兼容性更改。使用 C18,代码编译和链接得很好。使用 XC8,编译正常,但链接步骤失败并出现以下错误:
Error [500] ; 0. undefined symbols:
_putch(server.obj) _ENC_Init(server.obj) _ENC_WriteRegister(server.obj) _ENC_ReadRegister(server.obj)
随着编译成功,我想找到了原型,因此.h
文件包含在内。我猜编译器找不到.c
文件。
该函数putch
没有在我自己的程序中调用,但它被调用putchar
并且我使用该函数。开头的函数ENC_
是我自己的函数。
我在 XC8 工具包的“包含搜索路径”中添加了两条路径:
C:\Program Files (x86)\Microchip\xc8\v1.12\sources
,我相信编译器的.c
文件所在的位置C:\...\lib
,我自己的.c
文件所在的位置。
但是,我仍然收到错误消息。
我该如何解决这个问题?
这是完整的日志:
Advisory[1233] Employing 18F4620 errata work-arounds:
Advisory[1234] * Corrupted fast interrupt shadow registers
Advisory[1234] * Data in RAM location can be corrupted if async. reset occurs during write
Warning [1273] ; . Omniscient Code Generation not available in Free mode
cgpic18 "--edf=C:\Program Files (x86)\Microchip\xc8\v1.12\dat\en_msgs.txt" --cmode=htc -Og9s -q -E1 -w9 -PMS0:code:0@CODE=00h-0FFFFh -PMS0:code:0@CONST=00h-0FFFFh -PMS0:code:0@SMALLCONST=01000h-010FFhx240 -PMS0:code:0@MEDIUMCONST=01000h-0FFFFh -PMS1:data:8@COMRAM=01h-07Fh -PMS1:data:0@ABS1=00h-0F7Fh -PMS1:data:0@BIGRAM=01h-0F7Fh -PMS1:data:0@RAM=080h-0FFh,0100h-01FFhx14,0F00h-0F7Fh -PMS1:data:400@BANK0=080h-0FFh -PMS1:data:800@BANK1=0100h-01FFh -PMS1:data:1000@BANK2=0200h-02FFh -PMS1:data:2000@BANK3=0300h-03FFh -PMS1:data:0@BANK4=0400h-04FFh -PMS1:data:0@BANK5=0500h-05FFh -PMS1:data:0@BANK6=0600h-06FFh -PMS1:data:0@BANK7=0700h-07FFh -PMS1:data:0@BANK8=0800h-08FFh -PMS1:data:0@BANK9=0900h-09FFh -PMS1:data:0@BANK10=0A00h-0AFFh -PMS1:data:0@BANK11=0B00h-0BFFh -PMS1:data:0@BANK12=0C00h-0CFFh -PMS1:data:0@BANK13=0D00h-0DFFh -PMS1:data:0@BANK14=0E00h-0EFFh -PMS1:data:0@BANK15=0F00h-0F7Fh -PMS1:data:0@SFR=0F80h-0FFFh -PMS3:config:0@CONFIG=0300000h-030000Dh -PMS2:eedata:0@EEDATA=0F00000h-0F003FFh -PMS4:idloc:0@IDLOC=0200000h-0200007h "--cfgdata=C:\Program Files (x86)\Microchip\xc8\v1.12\dat\cfgdata\18f4620.cfgdata" --cfgprefix=__CFG_ -MLFSROK -MIEEE_DBL -MIEEE_FLT -PPIC18F4620,1,65535,3967,8194,31,1,0,127,0 -fp -AC:\Users\...\AppData\Local\Temp\s234. --funcdat=C:\Users\...\AppData\Local\Temp\s234.5 --addrqual=ignore --runtime=init --runtime=clear server.p1 "C:\Program Files (x86)\Microchip\xc8\v1.12\lib\pic18-plib-htc-18f4620.lpp" "C:\Program Files (x86)\Microchip\xc8\v1.12\lib\pic18-stdlib-htc-d32-f32.lpp"
cgpic18 "--edf=C:\Program Files (x86)\Microchip\xc8\v1.12\dat\en_msgs.txt" --cmode=htc -q -E1 -Dserver.sdb -PMS0:code:0@CODE=00h-0FFFFh -PMS0:code:0@CONST=00h-0FFFFh -PMS0:code:0@SMALLCONST=01000h-010FFhx240 -PMS0:code:0@MEDIUMCONST=01000h-0FFFFh -PMS1:data:8@COMRAM=01h-07Fh -PMS1:data:0@ABS1=00h-0F7Fh -PMS1:data:0@BIGRAM=01h-0F7Fh -PMS1:data:0@RAM=080h-0FFh,0100h-01FFhx14,0F00h-0F7Fh -PMS1:data:400@BANK0=080h-0FFh -PMS1:data:800@BANK1=0100h-01FFh -PMS1:data:1000@BANK2=0200h-02FFh -PMS1:data:2000@BANK3=0300h-03FFh -PMS1:data:0@BANK4=0400h-04FFh -PMS1:data:0@BANK5=0500h-05FFh -PMS1:data:0@BANK6=0600h-06FFh -PMS1:data:0@BANK7=0700h-07FFh -PMS1:data:0@BANK8=0800h-08FFh -PMS1:data:0@BANK9=0900h-09FFh -PMS1:data:0@BANK10=0A00h-0AFFh -PMS1:data:0@BANK11=0B00h-0BFFh -PMS1:data:0@BANK12=0C00h-0CFFh -PMS1:data:0@BANK13=0D00h-0DFFh -PMS1:data:0@BANK14=0E00h-0EFFh -PMS1:data:0@BANK15=0F00h-0F7Fh -PMS1:data:0@SFR=0F80h-0FFFh -PMS3:config:0@CONFIG=0300000h-030000Dh -PMS2:eedata:0@EEDATA=0F00000h-0F003FFh -PMS4:idloc:0@IDLOC=0200000h-0200007h "--cfgdata=C:\Program Files (x86)\Microchip\xc8\v1.12\dat\cfgdata\18f4620.cfgdata" --cfgprefix=__CFG_ -MLFSROK -MIEEE_DBL -MIEEE_FLT -PPIC18F4620,1,65535,3967,8194,31,1,0,127,0 -AC:\Users\...\AppData\Local\Temp\s234. --funcdat=C:\Users\...\AppData\Local\Temp\s234.5 --addrqual=ignore --runtime=init --runtime=clear server.p1 "C:\Program Files (x86)\Microchip\xc8\v1.12\lib\pic18-plib-htc-18f4620.lpp" "C:\Program Files (x86)\Microchip\xc8\v1.12\lib\pic18-stdlib-htc-d32-f32.lpp"
aspic18 "--edf=C:\Program Files (x86)\Microchip\xc8\v1.12\dat\en_msgs.txt" --cmode=htc -E1 "-CC:\Program Files (x86)\Microchip\xc8\v1.12\dat\picc-18.ini" -ver=V1.12 -lserver.lst --opt= -n -18F4620 --comdiv=127 -no_pa -oserver.obj C:\Users\...\AppData\Local\Temp\s234.
aspic18 "--edf=C:\Program Files (x86)\Microchip\xc8\v1.12\dat\en_msgs.txt" --cmode=htc -E1 "-CC:\Program Files (x86)\Microchip\xc8\v1.12\dat\picc-18.ini" -ver=V1.12 --opt= -n -18F4620 --comdiv=127 -no_pa -oC:\Users\...\AppData\Local\Temp\s234.obj C:\Users\...\AppData\Local\Temp\s234.as
hlink "--edf=C:\Program Files (x86)\Microchip\xc8\v1.12\dat\en_msgs.txt" -cs -h+server.sym -z -w9 -Q18F4620 -Mserver.map -E1 -ver=XC8#PRO##V1.12 -ACODE=00h-0FFFFh -ACONST=00h-0FFFFh -ASMALLCONST=01000h-010FFhx240 -AMEDIUMCONST=01000h-0FFFFh -ACOMRAM=01h-07Fh -AABS1=00h-0F7Fh -ABIGRAM=01h-0F7Fh -ARAM=080h-0FFh,0100h-01FFhx14,0F00h-0F7Fh -ABANK0=080h-0FFh -ABANK1=0100h-01FFh -ABANK2=0200h-02FFh -ABANK3=0300h-03FFh -ABANK4=0400h-04FFh -ABANK5=0500h-05FFh -ABANK6=0600h-06FFh -ABANK7=0700h-07FFh -ABANK8=0800h-08FFh -ABANK9=0900h-09FFh -ABANK10=0A00h-0AFFh -ABANK11=0B00h-0BFFh -ABANK12=0C00h-0CFFh -ABANK13=0D00h-0DFFh -ABANK14=0E00h-0EFFh -ABANK15=0F00h-0F7Fh -ASFR=0F80h-0FFFh -preset_vec=00h,intcode,intcodelo,powerup,init,end_init -pramtop=01000h -psmallconst=SMALLCONST -pmediumconst=MEDIUMCONST -pconst=CONST -AFARRAM=00h-00h -ACONFIG=0300000h-030000Dh -pconfig=CONFIG -AIDLOC=0200000h-0200007h -pidloc=IDLOC -AEEDATA=0F00000h-0F003FFh -peeprom_data=EEDATA -prdata=COMRAM,nvrram=COMRError [500] ; 0. undefined symbols:
_putch(server.obj) _ENC_Init(server.obj) _ENC_WriteRegister(server.obj) _ENC_ReadRegister(server.obj)
AM,nvbit=COMRAM,rbss=COMRAM,rbit=COMRAM -pfarbss=FARRAM,fardata=FARRAM -pintsave_regs=BIGRAM,bigbss=BIGRAM,bigdata=BIGRAM -pbss=RAM -pidata=CODE,irdata=CODE,ibigdata=CODE,ifardata=CODE C:\Users\...\AppData\Local\Temp\s234.obj server.obj
del l.obj
del C:\Users\...\AppData\Local\Temp\s234.
del C:\Users\...\AppData\Local\Temp\s234.1
del C:\Users\...\AppData\Local\Temp\s234.2
del C:\Users\...\AppData\Local\Temp\s234.3
del C:\Users\...\AppData\Local\Temp\s234.4
del C:\Users\...\AppData\Local\Temp\s234.5
del C:\Users\...\AppData\Local\Temp\s234.as
del C:\Users\...\AppData\Local\Temp\s234.obj
(908) exit status = 1