//main.cpp
#include <stdio.h>
extern "C" void asmFunc();
int main() {
asmFunc();
return 0;
}
asm.asm
.data
var byte "Hello",10
.code
public asmFunc
externdef printf:proc
asmFunc proc
sub rsp,56
lea rcx,var
call printf
add rsp,56
ret
asmFunc endp
end
When trying build the project in visual studio There is message said
Unresolved external symbol printf refereenced in function
And when I call printf
before calling asmFunc
, the error is gone.
But I want only call printf
in assembly
VS Build commands:
C++
/JMC /permissive- /ifcOutput "x64\Debug\" /GS /W3 /Zc:wchar_t /ZI /Gm- /Od /sdl /Fd"x64\Debug\vc143.pdb" /Zc:inline /fp:precise /D "_DEBUG" /D "_CONSOLE" /D "_UNICODE" /D "UNICODE" /errorReport:prompt /WX- /Zc:forScope /RTC1 /Gd /MDd /FC /Fa"x64\Debug\" /EHsc /nologo /Fo"x64\Debug\" /Fp"x64\Debug\assembly.pch" /diagnostics:column
linker
/OUT:"x64\Debug\assembly.exe" /MANIFEST /NXCOMPAT /PDB:"\x64\Debug\assembly.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" /DEBUG /MACHINE:X64 /INCREMENTAL /PGD:"x64\Debug\assembly.pgd" /SUBSYSTEM:CONSOLE /MANIFESTUAC:"level='asInvoker' uiAccess='false'" /ManifestFile:"x64\Debug\assembly.exe.intermediate.manifest" /LTCGOUT:"x64\Debug\assembly.iobj" /ERRORREPORT:PROMPT /ILK:"x64\Debug\assembly.ilk" /NOLOGO /TLBID:1