blinky.zip,gcc-section,Teensy ++ v.2中的说明。 zip文件中包含Makefile和blinky.c。我通过在开始时定义F_CPU来修改blinky.c,因为不使用Makefile,请参阅下文。那么为什么我会得到错误,如何为at90usb1286芯片编译C文件?
$ avr-gcc -mmcu=atmega88 blinky.c
In file included from blinky.c:28:
/usr/local/lib/gcc/avr/4.2.2/../../../../avr/include/util/delay.h:90:3: warning: #warning "Compiler optimizations disabled; functions from <util/delay.h> won't work as designed"
/tmp//ccB66ecl.o: In function `main':
blinky.c:(.text+0x3e): undefined reference to `usb_init'
/tmp//ccB66ecl.o: In function `morse_character':
blinky.c:(.text+0x24c): undefined reference to `print_P'
blinky.c:(.text+0x36e): undefined reference to `print_P'
blinky.c:(.text+0x378): undefined reference to `usb_debug_putchar'
blinky.c:(.text+0x37e): undefined reference to `print_P'
blinky.c:(.text+0x386): undefined reference to `print_P'
blinky.c:(.text+0x390): undefined reference to `usb_debug_putchar'
blinky.c:(.text+0x394): undefined reference to `usb_debug_putchar'
blinky.c:(.text+0x416): undefined reference to `print_P'
blinky.c:(.text+0x4fa): undefined reference to `print_P'
blinky.c:(.text+0x6f8): undefined reference to `print_P'
/tmp//ccB66ecl.o: In function `morse_P':
blinky.c:(.text+0x834): undefined reference to `print_P'
答案 0 :(得分:0)
这些是链接错误。你只能进行编译(注意我添加了-c
标志):
avr-gcc -c -mmcu=atmega88 blinky.c
然后,您必须将其与其他对象链接以创建二进制文件。
或者,您可以在单个命令行中提供所有源文件,编译器将编译并链接它们:
avr-gcc -mmcu=atmega88 blinky.c print.c usb_debug_only.c