致命错误LNK1120:使用VS2010的汇编语言的1个未解析的外部

时间:2015-03-05 18:01:15

标签: visual-studio-2010 assembly x86 masm irvine32

Comment @
Using Programming Exercise 6 in Chapter 4 as a starting point, 
write a program that generates the first 47 values in the Fibonacci 
series, stores them in an array of doublewords, and writes the 
doubleword array to a disk file.
@

INCLUDE c:\Irvine\Irvine32.inc

FIB_COUNT = 47  ; number of values to generate

.data
fileHandle DWORD ?
filename BYTE "fibonacci.bin",0
array DWORD FIB_COUNT DUP(?)

.code
main2sub PROC

; Generate the array of values

mov esi, OFFSET array
mov ecx, LENGTHOF array
call generate_fibonacci

; Create the file, call CreateOutputFile

mov edx,OFFSET filename
call CreateOutputFile
mov fileHandle, eax

; Write the array to the file, call WriteToFile

mov eax, fileHandle
mov edx, OFFSET array
mov ecx, FIB_COUNT * 4
call WriteToFile

; Close the file, call CloseFile    

mov eax, fileHandle
call CloseFile

exit
main2sub ENDP

;------------------------------------------------------------
generate_fibonacci PROC USES eax ebx ecx edx
;
; Generates fibonacci values and stores in an array.
; Receives: ESI points to the array, 
;           ECX = count
; Returns: nothing
;------------------------------------------------------------


mov ebx, 1
mov ecx, 0

L1:
add ebx, ecx
mov [esi], eax

call WriteDec
call Crlf

inc esi
xchg ebx, eax

loop L1     ;end of looping

    ret
generate_fibonacci ENDP

END main2sub

这是我第一次学习汇编语言的学期。我不知道如何处理此错误消息“致命错误LNK1120:1未解析的外部”。任何人都可以帮助我吗?

1 个答案:

答案 0 :(得分:2)

链接器无法找到库文件Irvine32.libKernel32.Lib和/或User32.Lib。它们与Irvine32.inc

位于同一文件夹中

最简单的方法是通过MASM指令通知ML这些库。在INCLUDE c:\Irvine\Irvine32.inc

后面插入以下三行
INCLUDELIB c:\Irvine\Irvine32.lib
INCLUDELIB c:\Irvine\Kernel32.lib
INCLUDELIB c:\Irvine\User32.lib