I was trying to follow up a tutorial on mixing c++ and x86_assembly with masm on visual studio
I have done all the steps after the instructor and the same steps found repeated here all the steps mentioned is done except for step 8 8) Change the Active solution platform to x64
After Doing all the above steps on trying to build the solution it gives about 18 errors of LNK2019
The error is resolved only when I remove the asm file from the solution
here is my c++ code
// CalculatreSum.cpp : This file contains the 'main' function. Program execution begins and ends there.
#include <iostream>
extern "C" int AdderAsm(int, int, int);
int AdderCpp(int, int, int);
int main() {
int sum;
sum = AdderCpp(4, 5, 6);
printf("Sum from AdderCpp is: %d\n", sum);
sum = AdderAsm(4, 5, 6);
printf("Sum from AdderAsm is: %d\n", sum);
}
int AdderCpp(int a, int b, int c) {
return a + b + c;
}
and here is my x86 assembly one
.386
.model flat, c
.code
AdderAsm proc
push ebp;
mov ebp, esp;
mov eax, [ebp + 8];
mov ebx, [ebp + 12];
mov ecx, [ebp + 16];
add eax, ebx;
add eax, ecx;
pop ebp;
ret
AdderAsm ENDP
END AdderAsm
[EDIT] The Error messages in the log
17 unresolved externals C:\Users\mahmo\source\repos\CalculatreSum\Debug\CalculatreSum.exe 1
unresolved external symbol _strcat_s referenced in function "void __cdecl _RTC_StackFailure(void *,char const *)" (?_RTC_StackFailure@@YAXPAXPBD@Z) C:\Users\mahmo\source\repos\CalculatreSum\CalculatreSum\MSVCRTD.lib(error.obj) 1
unresolved external symbol _strcpy_s referenced in function "void __cdecl _RTC_StackFailure(void *,char const *)" (?_RTC_StackFailure@@YAXPAXPBD@Z) C:\Users\mahmo\source\repos\CalculatreSum\CalculatreSum\MSVCRTD.lib(error.obj) 1
unresolved external symbol _terminate referenced in function __except_handler4_noexcept C:\Users\mahmo\source\repos\CalculatreSum\CalculatreSum\MSVCRTD.lib(chandler4_noexcept.obj) 1
unresolved external symbol _wcscpy_s referenced in function "int __cdecl GetPdbDllPathFromFilePath(wchar_t const *,wchar_t *,unsigned int)" (?GetPdbDllPathFromFilePath@@YAHPB_WPA_WI@Z) C:\Users\mahmo\source\repos\CalculatreSum\CalculatreSum\MSVCRTD.lib(pdblkup.obj) 1
unresolved external symbol __CrtDbgReport referenced in function __CRT_RTC_INIT C:\Users\mahmo\source\repos\CalculatreSum\CalculatreSum\MSVCRTD.lib(init.obj) 1
unresolved external symbol __CrtDbgReportW referenced in function __CRT_RTC_INITW C:\Users\mahmo\source\repos\CalculatreSum\CalculatreSum\MSVCRTD.lib(init.obj) 1
unresolved external symbol __except_handler4_common referenced in function __except_handler4 C:\Users\mahmo\source\repos\CalculatreSum\CalculatreSum\MSVCRTD.lib(chandler4gs.obj) 1
unresolved external symbol __imp____acrt_iob_func referenced in function _printf C:\Users\mahmo\source\repos\CalculatreSum\CalculatreSum\CalculatreSum.obj 1
unresolved external symbol __imp____stdio_common_vfprintf referenced in function __vfprintf_l C:\Users\mahmo\source\repos\CalculatreSum\CalculatreSum\CalculatreSum.obj 1
unresolved external symbol __wmakepath_s referenced in function "int __cdecl GetPdbDllPathFromFilePath(wchar_t const *,wchar_t *,unsigned int)" (?GetPdbDllPathFromFilePath@@YAHPB_WPA_WI@Z) C:\Users\mahmo\source\repos\CalculatreSum\CalculatreSum\MSVCRTD.lib(pdblkup.obj) 1
unresolved external symbol __wsplitpath_s referenced in function "int __cdecl GetPdbDllPathFromFilePath(wchar_t const *,wchar_t *,unsigned int)" (?GetPdbDllPathFromFilePath@@YAHPB_WPA_WI@Z) C:\Users\mahmo\source\repos\CalculatreSum\CalculatreSum\MSVCRTD.lib(pdblkup.obj) 1
unresolved external symbol ___current_exception referenced in function __except_handler4_noexcept C:\Users\mahmo\source\repos\CalculatreSum\CalculatreSum\MSVCRTD.lib(chandler4_noexcept.obj) 1
unresolved external symbol ___current_exception_context referenced in function __except_handler4_noexcept C:\Users\mahmo\source\repos\CalculatreSum\CalculatreSum\MSVCRTD.lib(chandler4_noexcept.obj) 1
unresolved external symbol ___stdio_common_vsprintf_s referenced in function __vsprintf_s_l C:\Users\mahmo\source\repos\CalculatreSum\CalculatreSum\MSVCRTD.lib(error.obj) 1
unresolved external symbol ___vcrt_GetModuleFileNameW referenced in function "struct HINSTANCE__ * __cdecl GetPdbDll(void)" (?GetPdbDll@@YAPAUHINSTANCE__@@XZ) C:\Users\mahmo\source\repos\CalculatreSum\CalculatreSum\MSVCRTD.lib(pdblkup.obj) 1
unresolved external symbol ___vcrt_GetModuleHandleW referenced in function "struct HINSTANCE__ * __cdecl GetPdbDll(void)" (?GetPdbDll@@YAPAUHINSTANCE__@@XZ) C:\Users\mahmo\source\repos\CalculatreSum\CalculatreSum\MSVCRTD.lib(pdblkup.obj) 1
unresolved external symbol ___vcrt_LoadLibraryExW referenced in function "struct HINSTANCE__ * __cdecl GetPdbDll(void)" (?GetPdbDll@@YAPAUHINSTANCE__@@XZ) C:\Users\mahmo\source\repos\CalculatreSum\CalculatreSum\MSVCRTD.lib(pdblkup.obj) 1