Link doesn't appear to include functions from delay.h.
Attempting to build using MPLABX. Simple command line make also attempted. Symbol is always missing.
SDCC Version used: Both release and snapshot. Current version information:
SDCC : mcs51/z80/z180/r2k/r3ka/gbz80/tlcs90/ds390/pic16/pic14/TININative/ds400/hc08/s08/stm8 3.6.5 #9866 (MINGW64)
published under GNU General Public License (GPL)
Source file used to reproduce problem:
#include <pic18fregs.h>
#include <delay.h>
#pragma config OSC=INTIO67, PWRT=ON, BOREN=OFF, WDT=OFF, PBADEN=ON, MCLRE=OFF
#pragma config STVREN=OFF, LVP=OFF, XINST=OFF, DEBUG=OFF
#define LED_LAT LATCbits.LATC0
#define LED_TRIS TRISCbits.TRISC0
/*
*
*/
int main(int argc, char** argv) {
argc;
argv;
OSCCON = 0b01110000;
ADCON0 = 0b00000000;
ADCON1 = 0b00000000;
TRISC = 0X00;
while (1) {
LED_LAT = !LED_LAT; // Toggle LED
delay1ktcy(125); //500ms @ 1MHz
}
}
MPLABX verbose output:
make -f nbproject/Makefile-default.mk SUBPROJECTS= .build-conf
make[1]: Entering directory 'E:/electronics/trunk/SDCCTest'
make -f nbproject/Makefile-default.mk dist/default/production/SDCCTest.production.hex
make[2]: Entering directory 'E:/electronics/trunk/SDCCTest'
gnumkdir -p "build/default/production"
rm -f build/default/production/main.o
"C:\Program Files\SDCC\bin\SDCC.exe" --use-non-free --verbose -V -c -mpic16 -p18f2620 main.c -obuild/default/production/main.o
Processor: 18f2620
sdcc: Calling preprocessor...
sdcc: sdcpp -nostdinc -Wall -std=c11 -D__18f2620 -D__SDCC_PIC18F2620 -D__STACK_MODEL_SMALL -obj-ext=.o -D__SDCC_CHAR_UNSIGNED -D__SDCC_USE_NON_FREE -D__SDCC_ALL_CALLEE_SAVES -D__SDCC=3_6_5 -D__SDCC_VERSION_MAJOR=3 -D__SDCC_VERSION_MINOR=6 -D__SDCC_VERSION_PATCH=5 -D__SDCC_REVISION=9866 -D__SDCC_pic16 -D__STDC_NO_COMPLEX__=1 -D__STDC_NO_THREADS__=1 -D__STDC_NO_ATOMICS__=1 -D__STDC_NO_VLA__=1 -D__STDC_ISO_10646__=201409L -D__STDC_UTF_16__=1 -D__STDC_UTF_32__=1 -isystem "C:\Program Files\SDCC\bin\..\include\pic16" -isystem "C:\Program Files\SDCC\bin\..\include" -isystem "C:\Program Files\SDCC\bin\..\non-free\include\pic16" -isystem "C:\Program Files\SDCC\bin\..\non-free\include" "main.c"
+ C:\PROGRA~1\SDCC\bin\sdcpp.exe -nostdinc -Wall -std=c11 -D__18f2620 -D__SDCC_PIC18F2620 -D__STACK_MODEL_SMALL -obj-ext=.o -D__SDCC_CHAR_UNSIGNED -D__SDCC_USE_NON_FREE -D__SDCC_ALL_CALLEE_SAVES -D__SDCC=3_6_5 -D__SDCC_VERSION_MAJOR=3 -D__SDCC_VERSION_MINOR=6 -D__SDCC_VERSION_PATCH=5 -D__SDCC_REVISION=9866 -D__SDCC_pic16 -D__STDC_NO_COMPLEX__=1 -D__STDC_NO_THREADS__=1 -D__STDC_NO_ATOMICS__=1 -D__STDC_NO_VLA__=1 -D__STDC_ISO_10646__=201409L -D__STDC_UTF_16__=1 -D__STDC_UTF_32__=1 -isystem "C:\Program Files\SDCC\bin\..\include\pic16" -isystem "C:\Program Files\SDCC\bin\..\include" -isystem "C:\Program Files\SDCC\bin\..\non-free\include\pic16" -isystem "C:\Program Files\SDCC\bin\..\non-free\include" "main.c"
sdcc: Generating code...
sdcc: Calling assembler...
sdcc: gpasm -D__STACK_MODEL_SMALL -o "build/default/production/main.o" -c "build/default/production/main".asm
+ C:\PROGRA~2\gputils\bin\gpasm.exe -D__STACK_MODEL_SMALL -o "build/default/production/main.o" -c "build/default/production/main".asm
gnumkdir -p dist/default/production
"C:\Program Files\SDCC\bin\SDCC.exe" -Wl-c -Wl-m --use-non-free --verbose -V -mpic16 -p18f2620 build/default/production/main.o -odist/default/production/SDCCTest.production.hex
make[2]: *** [dist/default/production/SDCCTest.production.hex] Error 1
make[1]: *** [.build-conf] Error 2
make: *** [.build-impl] Error 2
message: Using default linker script "C:\Program Files (x86)\gputils\lkr\18f2620_g.lkr".
error: Missing definition for symbol "_delay1ktcy", required by "build/default/production/main.o".
Processor: 18f2620
sdcc: Calling linker...
+ C:\PROGRA~2\gputils\bin\gplink.exe -I"C:\Program Files\SDCC\bin\..\lib\pic16" -I"C:\Program Files\SDCC\bin\..\non-free\lib\pic16" -c -m -w -r -o "dist/default/production/SDCCTest.production.hex" "build/default/production/main.o" "crt0iz.o" "libdev18f2620.lib" "libsdcc.lib"
+ C:\PROGRA~2\gputils\bin\gplink.exe -I"C:\Program Files\SDCC\bin\..\lib\pic16" -I"C:\Program Files\SDCC\bin\..\non-free\lib\pic16" -c -m -w -r -o "dist/default/production/SDCCTest.production.hex" "build/default/production/main.o" "crt0iz.o" "libdev18f2620.lib" "libsdcc.lib" returned errorcode 1
nbproject/Makefile-default.mk:110: recipe for target 'dist/default/production/SDCCTest.production.hex' failed
make[2]: Leaving directory 'E:/electronics/trunk/SDCCTest'
nbproject/Makefile-default.mk:84: recipe for target '.build-conf' failed
make[1]: Leaving directory 'E:/electronics/trunk/SDCCTest'
nbproject/Makefile-impl.mk:39: recipe for target '.build-impl' failed
Edit: Made more readable.
Sorry for the terribly formatting, this is my first bug report.
Diff:
Explicitly linking with libc18f.lib resolves external references to delay functions. I'm not sure if this is a bug or not, I don't see this library explicitly specified in the wiki examples so I'm assuming it should be linked by default for PIC18 devices. If not, then this is not a bug. Thanks!