2012-09-28 12 views
0

所以,我對我工作的一些彙編代碼生成文件,當我嘗試建立我的代碼,我得到以下輸出:的Makefile NASM錯誤:多個輸入文件中指定

Makefile:32: warning: overriding commands for target `obj' 
Makefile:29: warning: ignoring old commands for target `obj' 
nasm -f elf64 -g -F stabs main.asm -l spacelander .lst 
nasm: error: more than one input file specified 
type `nasm -h' for help 
make: *** [obj] Error 1 

然而, ,當我爲此谷歌這似乎是由於LD的鏈接器問題而不是NASM本身(只有錯誤而不是LD的NASM輸出),並且我只有一個源文件打印簡單的文本輸出作爲測試。在例子this中,OP能夠執行他的代碼;我的甚至不會建立。我的源文件非常好,因爲在我修改代碼之前,代碼已經建好,運行良好,沒有任何問題。我爲了將任何.o文件複製到obj/目錄以及將目標複製到bin/目錄中而進行了更改。

這個問題的原因是什麼?我幾乎是積極的,它與代碼無關,是由於Makefile本身。

爲了完整起見,我將粘貼我的Makefile和彙編源代碼。


來源

bits 32 

section [.bss] 

section [.data] 

; Store three lines in the same string. 
; This is just for test purposes. 

Title: db "------SPACE LANDER-----", 10, \ 
      "------SPACE LANDER-----", 10, \ 
      "------SPACE LANDER-----", 10 

Len: equ $-Title 

section [.text] 

    global _start 

_start: 

    mov  eax, 4  ; Syswrite 
    mov  ebx, 1  ; To stdout 
    mov  ecx, Title ; ecx stores title to print 
    mov edx, Len ; store offset of len in edx 

    int  0x80  ; call kernel, do print 

exit: 

    mov  eax, 1 ; exit 
    mov ebx, 0 ; return 0 
    int  0x80  ; call kernel, exit safely (hopefully) 

的Makefile

ASM := nasm 
ARGS := -f 
FMT := elf64 
OPT := -g -F stabs 

SRC := main.asm 

#SRC_EXT := asm 
#^unused due to suspected error causing. 

OBJDIR := obj 
TARGETDIR := bin 

OBJ := $(addprefix $(OBJDIR)/,$(patsubst %.asm, %.o, $(wildcard *.asm))) 
TARGET := spacelander 

.PHONY: all clean 

all: $(OBJDIR) $(TARGET) 

$(OBJDIR): 
    mkdir $(OBJDIR) 

$(OBJDIR)/%.o: $(SRC) 
    $(ASM) $(ARGS) $(FMT) $(OPT) $(SRC) -l $(TARGET).lst 

$(TARGET): $(OBJ) 
    ld -o $(TARGET) $(OBJ) 

clean: 
    @rm -f $(TARGET) $(wildcard *.o) 
    @rm -rf $(OBJDIR) 

回答

1

可能是由於這個命令多餘的空格:

nasm -f elf64 -g -F stabs main.asm -l spacelander .lst 

因爲你有多餘的空格在$(TARGET)年底,因爲你有額外的空間,在這行的末尾:

TARGET := spacelander 

嘗試去掉那些多餘的空格。

+1

'OBJDIR:= obj'的末尾還有一個額外的空間,即使'nasm'命令執行成功,它也會引發警告消息,並且會損壞構建的其餘部分。 – Beta

相關問題