[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [avr-chat] HowTo split a program into several files ?
From: |
Vincent Trouilliez |
Subject: |
Re: [avr-chat] HowTo split a program into several files ? |
Date: |
Mon, 12 Sep 2005 21:04:21 +0200 |
On Mon, 2005-09-12 at 19:33 +0200, Vincent Trouilliez wrote:
> > Or you can tell the compiler to directly compile and link seperate source
> > files by just
> > feeding them all into gcc at once (gcc -o foo main.c foo.c morefiles.c ...)
Till, I am getting there: I added a couple includes to lcd.h and now gcc
-o foo main.c lcd.c doesn't complain anymore :-)
Thanks for your further comments on includes which I just read.
Okay I am almost there. Problem : I am hardly confident with the ins and
out of gcc and all related tools. So so far I have used all the command
stated in the 'demo' project in avr-libc, and put them together in a
script, so that everything is done at once and all the files are
generated automatically :
avr-gcc -g -Os -mmcu=atmega32 -c demo.c
avr-gcc -g -mmcu=atmega32 -Wl,-Map,demo.map -o demo.elf demo.o
avr-objdump -h -S demo.elf > demo.lst
avr-objcopy -j .text -j .data -O ihex "$1".elf "$1".hex
This worked perectly so far, and am now therefore trying to accomodate
this script for use with multiple files. So my best attempt is :
avr-gcc -g -Os -mmcu=atmega32 -c main.c lcd.c
avr-gcc -g -mmcu=atmega32 -Wl,-Map, main.map -o main.elf main.o lcd.o
avr-objdump -h -S main.elf > main.lst
avr-objcopy -j .text -j .data -O ihex main.elf main.hex
My understanding is :
1) gcc -c main.c lcd.c will compile the two .c files and generate
main.o and lcd.o.
2) Then gcc -o is used to link a number of .o files into a single .elf
executable file
3) This .elf file is then used by avr-objdump and avr-objcopy to
generate a number of other files, among which we find the .hex that will
actually make it into the AVR chip.
That's the best/clearest reasoning I can come up with so far, I hope
it's not too crap :-/
Problem : phase 1) seems okay : main.o and lcd.o are created, but phase
2) fails : no .elf file is created :o( Of course phase 3) fails too as
it has no .elf file to work with.
So I guess I got the syntax of the gcc -o phase, wrong...right ?
Please help me correct this line... I feel I am a split hair from
success !! :-)
Regards,
--
Vince
- Re: [avr-chat] HowTo split a program into several files ?, (continued)
- Re: [avr-chat] HowTo split a program into several files ?, Andy Warner, 2005/09/12
- Re: [avr-chat] HowTo split a program into several files ?, Francisco Silva, 2005/09/12
- Re: [avr-chat] HowTo split a program into several files ?, Vincent Trouilliez, 2005/09/12
- Re: [avr-chat] HowTo split a program into several files ?, Vincent Trouilliez, 2005/09/12
- Re: [avr-chat] HowTo split a program into several files ?, Till Harbaum, 2005/09/12
- Re: [avr-chat] HowTo split a program into several files ?,
Vincent Trouilliez <=
- Message not available
- Re: [avr-chat] HowTo split a program into several files ?, Vincent Trouilliez, 2005/09/12
- Re: [avr-chat] HowTo split a program into several files ?, Joerg Wunsch, 2005/09/12
- Re: [avr-chat] HowTo split a program into several files ?, Vincent Trouilliez, 2005/09/12
- Re: [avr-chat] HowTo split a program into several files ?, Vincent Trouilliez, 2005/09/12
- Message not available
- Re: [avr-chat] HowTo split a program into several files ?, Vincent Trouilliez, 2005/09/12
- Re: [avr-chat] HowTo split a program into several files ?, David Kelly, 2005/09/12
- Re: [avr-chat] HowTo split a program into several files ?, Joerg Wunsch, 2005/09/13
- Re: [avr-chat] HowTo split a program into several files ?, Vincent Trouilliez, 2005/09/13
- Re: [avr-chat] HowTo split a program into several files ?, Joerg Wunsch, 2005/09/13
- Re: [avr-chat] HowTo split a program into several files ?, Vincent Trouilliez, 2005/09/13