只要在屬性-連接器-輸入-附加依賴項,加入須要的obj便可連接進去,支持通配符,如:f:\dir\*.objc++
彙編中的變量常量須要用public列出來,函數不須要,由於直接就是public的,直接能夠經過extern ... (c++用extern "C" ... )進行調用。api
x64的經過 extern fn:proc 便可調用c或其它obj的fn,好比:函數
;hello64.asm extrn MessageBoxA : proc extrn ExitProcess : proc .data text db 'Hello world!', 0 caption db 'Message', 0 .code main proc frame sub rsp, 28h .allocstack 28h .endprolog xor r9, r9 ;MB_OK lea r8, caption ;lpCaption lea rdx, text ;lpText xor rcx, rcx ;hWnd call MessageBoxA xor rcx, rcx call ExitProcess add rsp, 28h main endp end
x86的經過 fn proto便可調用c或其它obj的fn,若是是api,要加stdcall,和後面的原型,好比:code
;hello32.asm .386 .model flat MessageBoxA proto stdcall hwnd:dword, text:dword, caption:dword, buttons:dword ExitProcess proto stdcall exitcode:dword ;實際上這裏的原型有的能夠隨意填,有的卻必須保持一致,大概有overload,好比下面(GetProcAddress GetCurrentProcess 這兩個就必須跟原型一致): GetModuleHandleW proto stdcall void:dword DeleteCriticalSection proto stdcall void:dword InitializeCriticalSection proto stdcall void:dword EnterCriticalSection proto stdcall void:dword LeaveCriticalSection proto stdcall void:dword GetSystemInfo proto stdcall void:dword GetProcAddress proto stdcall handle:dword,procname:dword GetCurrentProcess proto stdcall .data text db 'Hello world!', 0 caption db 'Message', 0 .code main proc push 0 ;MB_OK push offset caption ;lpCaption push offset text ;lpText push 0 ;hWnd call MessageBoxA push 0 call ExitProcess main endp end