2

I wrote a C++ project with some assembly code files in it. The project files include a C++ file with a main function, and a test.asm file.

I configured the project according to the method of this link (external assembly file in visual studio). When I try to build the project, an error occurs.

Here is the file test.asm:

PUBLIC hello_from_asm
EXTERN puts:PROC

.data

    hello1 db "Hello from ASM.",0

.code

hello_from_asm PROC
    push rbp
    mov rbp, rsp
    sub rsp, 32                 ; Shadow Space
    and spl, -16                ; Align stack at 16

    lea rcx, hello1
    call puts

    leave                       ; Restore stack (rsp) & frame pointer (rbp)
    ret
hello_from_asm ENDP

END

I tried to build the project with both Visual Studio 2022 and x64 Native Tools Command Prompt for VS 2022 and got same error.

C:\Users\xxx\source\repos\ConsoleApplication31\ConsoleApplication31>msbuild
Microsoft (R) Build Engine version 17.1.0+ae57d105c for .NET Framework
Copyright (C) Microsoft Corporation. All rights reserved.

Build started 3/11/2022 1:41:55 PM.
Project "C:\Users\xxx\source\repos\ConsoleApplication31\ConsoleApplicatio
n31\ConsoleApplication31.vcxproj" on node 1 (default targets).
InitializeBuildStatus:
  Touching "x64\Debug\ConsoleA.a1ef7c5e.tlog\unsuccessfulbuild".
_MASM:
  Assembling test.asm...
  cmd.exe /C "C:\Users\xxx\AppData\Local\Temp\tmpa142d9f35bfd45cd9bb5f72c
  5caa0ee0.cmd"
  ml64.exe /c /nologo /Zi /Fo"x64\Debug\test.obj" /W3 /errorReport:prompt  /Tat
  est.asm
  'ml64.exe' is not recognized as an internal or external command,
  operable program or batch file.
C:\Program Files\Microsoft Visual Studio\2022\Community\MSBuild\Microsoft\VC\v1
70\BuildCustomizations\masm.targets(70,5): error MSB3721: The command "ml64.exe
 /c /nologo /Zi /Fo"x64\Debug\test.obj" /W3 /errorReport:prompt  /Tatest.asm" e
xited with code 1. [C:\Users\xxx\source\repos\ConsoleApplication31\Consol
eApplication31\ConsoleApplication31.vcxproj]
Done Building Project "C:\Users\xxx\source\repos\ConsoleApplication31\Con
soleApplication31\ConsoleApplication31.vcxproj" (default targets) -- FAILED.


Build FAILED.

"C:\Users\xxx\source\repos\ConsoleApplication31\ConsoleApplication31\Cons
oleApplication31.vcxproj" (default target) (1) ->
(_MASM target) ->
  C:\Program Files\Microsoft Visual Studio\2022\Community\MSBuild\Microsoft\VC\
v170\BuildCustomizations\masm.targets(70,5): error MSB3721: The command "ml64.e
xe /c /nologo /Zi /Fo"x64\Debug\test.obj" /W3 /errorReport:prompt  /Tatest.asm"
 exited with code 1. [C:\Users\xxx\source\repos\ConsoleApplication31\Cons
oleApplication31\ConsoleApplication31.vcxproj]

    0 Warning(s)
    1 Error(s)

Time Elapsed 00:00:00.48

informatik01
  • 16,038
  • 10
  • 74
  • 104
ZSY-ARCH
  • 83
  • 1
  • 7
  • `'ml64.exe' is not recognized as an internal or external command, operable program or batch file.` Is it able to locate your assembler? – Irelia Mar 11 '22 at 06:05
  • I can't find on the web whether Community Edition is supposed to include the assembler or not. If msbuild expects to find it, then it should be there. – Tim Roberts Mar 11 '22 at 06:11
  • Yes community edition includes it, I think you just need to specifically set a path for it. – Irelia Mar 11 '22 at 06:35
  • What if you try compiling 32 bit instead of 64? – Irelia Mar 11 '22 at 06:35
  • I tried compiling 32bit and 64bit but both failed – ZSY-ARCH Mar 11 '22 at 06:47
  • I can manually type ml64.exe /c /nologo /Zi /Fo"x64\Debug\test.obj" /Fl"" /W3 /errorReport:prompt /Tatest.asm to compile test.asm, but typing msbuild to compile the project fails – ZSY-ARCH Mar 11 '22 at 06:52
  • What is the error in Visual Studio. Are there any errors from editor before `build`? `for .NET Framework` This doesn't look like C++. – Minxin Yu - MSFT Mar 11 '22 at 08:28
  • 1
    Visual Studio has a modular install these days. The assembler won't be in default installs, since pretty much nobody writes assembly these days. – MSalters Mar 11 '22 at 09:28

0 Answers0