WinAVR GCC怎样编译多个C源文件???
http://cache.amobbs.com/bbs_upload782111/files_8/ourdev_176171.JPGhttp://cache.amobbs.com/bbs_upload782111/files_8/ourdev_176172.JPG
按KEIL C 方法在GCC中不能通过编译. #include <avr/io.h>
// 函数声明
static void Delay(void);
static void Port_Init(void);
int main(void)
{
unsigned char loop;
unsigned char Display_Code=
{
0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80
};
Port_Init();
while (1)
{
for (loop=0; loop<8; loop++)
{
PORTB = Display_Code;
Delay();
}
}
}
void Delay(void)
{
unsigned char x, y;
for (x=0; x<255; x++)
{
for (y=0; y<255; y++);
for (y=0; y<255; y++);
}
}
void Port_Init(void)
{
DDRB = 0xff; // 置PORTB端口为输出方向
PORTB = 0xff; // portb所有端口输出高电平
}
> "make.exe" all
-------- begin --------
avr-gcc (GCC) 3.4.1
Copyright (C) 2004 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
Compiling: main.c
avr-gcc -c -mmcu=atmega8 -I. -gstabs -Os -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums -Wall -Wstrict-prototypes -Wa,-adhlns=main.lst-std=gnu99 -Wp,-M,-MP,-MT,main.o,-MF,.dep/main.o.d main.c -o main.o
Linking: main.elf
avr-gcc -mmcu=atmega8 -I. -gstabs -Os -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums -Wall -Wstrict-prototypes -Wa,-adhlns=main.o-std=gnu99 -Wp,-M,-MP,-MT,main.o,-MF,.dep/main.elf.d main.o --output main.elf -Wl,-Map=main.map,--cref -lm
Creating load file for Flash: main.hex
avr-objcopy -O ihex -R .eeprom main.elf main.hex
Creating load file for EEPROM: main.eep
avr-objcopy -j .eeprom --set-section-flags=.eeprom="alloc,load" \
--change-section-lma .eeprom=0 -O ihex main.elf main.eep
Creating Extended Listing: main.lss
avr-objdump -h -S main.elf > main.lss
Creating Symbol Table: main.sym
avr-nm -n main.elf > main.sym
Size after:
main.elf:
section size addr
.text 172 0
.data 8 8388704
.bss 0 8388712
.noinit 0 8388712
.eeprom 0 8454144
.stab 756 0
.stabstr 1291 0
Total 2227
Errors: none
-------- end --------
> Process Exit Code: 0
象这样中同一个源文件中可以编译成功,为什么??? 需要修改Makefile文件 怎样修改Makefile文件才能多个源文件一起来编译呢? 通过自己的摸索,在GCC中编译多个文件成功;
修改makefile文件如下:
# List C source files here. (C dependencies are automatically generated.)
SRC = main.c Sys_Init.c Delay.c 好好学习,我也是刚用GCC,就是GCC如果编译出错不指示具体是哪一句,比较的麻烦.我是用GCC+UltraEdit-32做编译环境的 SRC = main.c Sys_Init.c Delay.c 学习一下, 学习 摸索ing. MAKEFILE :
##########################################################################################################
# List C source files here. (C dependencies are automatically generated.)
SRC = main.c timer0.c analog.c twislave.c BLMC.c
#printf_P.c
##########################################################################################################
# If there is more than one source file, append them above, or modify and
# uncomment the following:
#SRC += foo.c bar.c
# You can also wrap lines by appending a backslash to the end of the line:
#SRC += baz.c \
#xyzzy.c
# List Assembler source files here.
# Make them always end in a capital .S.Files ending in a lowercase .s
# will not be considered source files but generated files (assembler
# output from the compiler), and will be deleted upon "make clean"!
# Even though the DOS/Win* filesystem matches both .s and .S the same,
# it will preserve the spelling of the filenames, and gcc itself does
# care about how the name is spelled on its command-line.
ASRC = 请问大家 makefile中没有src也能编译成功,是不是不能用呢? SRC = $(wildcard *.c) $(wildcard inc/*.c)
然后做成模版,不用每次修改了。
页:
[1]