Hallo,
ich möchte in einem C++-Projekt, welches ich für den ATMEGA32 mit
avr-eclipse entwickle, Assembler-Quellcode in .S-Files einsetzen.
Nun weiß ich aber nicht, wie ich dem Linker in der Eclipse-IDE
verklickern soll, dass er diesen Quellcode einbindet.
Das Projekt enthält die Datei main.cpp:
1 | extern void asmfn (void);
|
2 |
|
3 | int main (void)
|
4 | {
|
5 | //asmfn();
|
6 | while(1);
|
7 | return 0;
|
8 | }
|
sowie asmpart.S:
1 | .section .text
|
2 | .global asmfn
|
3 |
|
4 | asmfn:
|
5 | ret
|
Beide Dateien werden kompiliert, es wird asmpart.o sowie main.o erzeugt,
und die asmfn taucht auch im .map-File mit dem Verweis auf asmpart.o
auf.
Wenn ich jedoch die Auskommentierung vor "asmfm()" entferne, erhalte ich
die Fehlermeldung:
1 | Building target: asmtest.elf
|
2 | Invoking: AVR C++ Linker
|
3 | avr-g++ -Wl,-Map,asmtest.map,--cref -mmcu=atmega32 -o"asmtest.elf" ./asmpart.o ./main.o
|
4 | ./main.o: In function `main':
|
5 | ../main.cpp:5: undefined reference to `asmfn()'
|
6 | make: *** [asmtest.elf] Error 1
|
Und wenn ich unter Project->Properties->AC/C++ Build->Settings->AVR C++
Linker->Objects die Datei asmpart.o manuell unter "Other Objects"
eintrage, erhalte ich die Fehlermeldung
1 | Invoking: AVR C++ Linker
|
2 | avr-g++ -Wl,-Map,asmtest.map,--cref -mmcu=atmega32 -o"asmtest.elf" ./asmpart.o ./main.o asmpart.o
|
3 | asmpart.o: In function `asmfn':
|
4 | ../asmpart.S:(.text+0x0): multiple definition of `asmfn'
|
5 | ./asmpart.o:../asmpart.S:(.text+0x0): first defined here
|
6 | ./main.o: In function `main':
|
7 | ../main.cpp:5: undefined reference to `asmfn()'
|
8 | make: *** [asmtest.elf] Error 1
|
Kann mir bitte jemand einen Tip geben?