主题:近来看一下,C语言与Win32下汇编模块引用的问题!
C的代码如下是一个模块,
#include<stdio.h>
extern int swap(int,int);
void main()
{
int a,b,c;
printf("ÊäÈëa,b:");
scanf("%d%d",&a,&b);
swap(a,b);
printf("a,bµÄֵΪ:%d %d\n",a,b);
}
汇编模块如下:,
.386
.model flat,stdcall
option casemap:none
;-------------------------------------------
includelib msvcrt.lib
printf proto C :sbyte,:vararg
;define header file(include)
.code
_swap proc argu_1:word,argu_2:word
mov ax,argu_1
mov bx,argu_2
mov argu_1,bx
mov argu_2,ax
ret
_swap endp
end
----------------------------------------------------------------------------
Linking...
LINK : warning LNK4098: defaultlib "msvcrt.lib" conflicts with use of other libs; use /NODEFAULTLIB:library
main.obj : error LNK2001: unresolved external symbol "int __cdecl swap(int,int)" (?swap@@YAHHH@Z)
Debug/1.exe : fatal error LNK1120: 1 unresolved externals
Error executing link.exe.
1.exe - 2 error(s), 1 warning(s)
#include<stdio.h>
extern int swap(int,int);
void main()
{
int a,b,c;
printf("ÊäÈëa,b:");
scanf("%d%d",&a,&b);
swap(a,b);
printf("a,bµÄֵΪ:%d %d\n",a,b);
}
汇编模块如下:,
.386
.model flat,stdcall
option casemap:none
;-------------------------------------------
includelib msvcrt.lib
printf proto C :sbyte,:vararg
;define header file(include)
.code
_swap proc argu_1:word,argu_2:word
mov ax,argu_1
mov bx,argu_2
mov argu_1,bx
mov argu_2,ax
ret
_swap endp
end
----------------------------------------------------------------------------
Linking...
LINK : warning LNK4098: defaultlib "msvcrt.lib" conflicts with use of other libs; use /NODEFAULTLIB:library
main.obj : error LNK2001: unresolved external symbol "int __cdecl swap(int,int)" (?swap@@YAHHH@Z)
Debug/1.exe : fatal error LNK1120: 1 unresolved externals
Error executing link.exe.
1.exe - 2 error(s), 1 warning(s)