我在Visual Studio(Win10 x64,Visual Studio 2015)中创建的asm项目中调用C函数时遇到问题。项目包含一个asm文件:
.586
.model flat, stdcall
option casemap:none
includelib msvcrt.lib
ExitProcess PROTO return:DWORD
extern printf:near
.data
text BYTE "Text", 0
.code
main PROC
push offset text
call printf
add esp,4
invoke ExitProcess,0
main ENDP
end main
当我构建项目时,链接器输出错误:
错误_main @ 0中引用的LNK2019无法解析的外部符号_printf
链接器输出参数:
/OUT:"C:\Users\apple\Documents\SP_Lab7\Debug\SP_Lab7_Demo.exe“ / MANIFEST:否/ NXCOMPAT /PDB:"C:\Users\apple\Documents\SP_Lab7\Debug\SP_Lab7_Demo.pdb” / DYNAMICBASE “ kernel32.lib”“ user32.lib”“ gdi32.lib”“ winspool.lib”“ comdlg32.lib”“ advapi32.lib”“ shell32.lib”“ ole32.lib”“ oleaut32.lib”“ uuid.lib” “ odbc32.lib”“ odbccp32.lib” / MACHINE:X86 / SAFESEH:NO / INCREMENTAL:NO /PGD:"C:\Users\apple\Documents\SP_Lab7\Debug\SP_Lab7_Demo.pgd“ / SUBSYSTEM:WINDOWS / MANIFESTUAC: “ level ='asInvoker'uiAccess ='false'” /ManifestFile:"Debug\SP_Lab7_Demo.exe.intermediate.manifest“ / ERRORREPORT:PROMPT / NOLOGO / TLBID:1
如果我发表评论call print,那么一切都会正常执行(甚至是Windows API函数)。有什么方法可以从asm文件中调用C函数,而无需创建包含以下内容的cpp文件<cstdio>?有可能吗?
白衣染霜花
翻过高山走不出你
大话西游666
相关分类