You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Linking the first example with the instructions given doesn't work #1
Also, I had to run this in x64 Native Tools Command Prompt for VS 2017, Developer Command Prompt for VS2017 suggested in the tutorial didn't work.
That's very strange; what are you seeing when you try to run this in the developer command prompt? For all intents and purposes that should be calling vcvarsall.bat, which is similar to what is being done in the example build script (so that it doesn't require to be run from within a developer command prompt itself):
Maybe they should be added to the "Hello, world" example as well?
Also, I had to run this in x64 Native Tools Command Prompt for VS 2017, Developer Command Prompt for VS2017 suggested in the tutorial didn't work.
That's very strange; what are you seeing when you try to run this in the developer command prompt? For all intents and purposes that should be calling vcvarsall.bat, which is similar to what is being done in the example build script (so that it doesn't require to be run from within a developer command prompt itself):
Let me know if something in the tutorial was otherwise unclear regarding the above!
This is the output I get if I run the command that worked for me in x64 Native Tools Command Prompt for VS 2019 (I upgraded to VS 2019 since I tried this earlier, but it seems that the same problems exist in that version as before).
C:\Users\Leppaaho\Documents\Ohjelmointi\Assembler>link hello_world.obj /subsystem:console /out:hello_world_basic.exe kernel32.lib legacy_stdio_definitions.lib msvcrt.lib
Microsoft (R) Incremental Linker Version 14.29.30038.1
Copyright (C) Microsoft Corporation. All rights reserved.
hello_world.obj : error LNK2001: unresolved external symbol ExitProcess
hello_world.obj : error LNK2001: unresolved external symbol printf
LINK : error LNK2001: unresolved external symbol mainCRTStartup
C:\Program Files (x86)\Windows Kits\10\lib\10.0.19041.0\um\x86\kernel32.lib : warning LNK4272: library machine type 'x86' conflicts with target machine type 'x64'
C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30037\lib\x86\legacy_stdio_definitions.lib : warning LNK4272: library machine type 'x86' conflicts with target machine type 'x64'
C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30037\lib\x86\msvcrt.lib : warning LNK4272: library machine type 'x86' conflicts with target machine type 'x64'
hello_world_basic.exe : fatal error LNK1120: 3 unresolved externals
Btw, when opening x64 Native Tools Command Prompt for VS 2019 it mentions that vcvarsall.bat script you mentioned
Activity
sonictk commentedon Jul 27, 2021
Hi @Hemaolle: thanks for the report! However, I'm slightly confused:
Maybe it wasn't clear, but the Writing A Build Script section does cover this: https://sonictk.github.io/asm_tutorial/#hello,worldrevisted/writingabuildscript . The example also does specify
/entry:mainas well:asm_tutorial/build.bat
Line 82 in 0731a14
This is also covered in the same section, and also specified in the example build script:
asm_tutorial/build.bat
Line 89 in 0731a14
That's very strange; what are you seeing when you try to run this in the developer command prompt? For all intents and purposes that should be calling
vcvarsall.bat, which is similar to what is being done in the example build script (so that it doesn't require to be run from within a developer command prompt itself):asm_tutorial/build.bat
Line 34 in 0731a14
Let me know if something in the tutorial was otherwise unclear regarding the above!
Hemaolle commentedon Jul 30, 2021
Ah, I suppose I could have been clearer about which section I was talking about. I didn't yet get to the build script part, this was about the "Hello, world" example: https://sonictk.github.io/asm_tutorial/#introduction/settingup/hello,world.
To clarify, I had to remove part
/entry:mainfrom the example link command given in the "Hello, world" example which wasMaybe they should be added to the "Hello, world" example as well?
This is the output I get if I run the command that worked for me in x64 Native Tools Command Prompt for VS 2019 (I upgraded to VS 2019 since I tried this earlier, but it seems that the same problems exist in that version as before).
Btw, when opening x64 Native Tools Command Prompt for VS 2019 it mentions that
vcvarsall.batscript you mentionedwhereas Developer Command Prompt for VS 2019 doesn't, it only prints this part:
Let me know if something needs further clarification! 🙂
sonictk commentedon Aug 5, 2021
Ah, I see. I think I can update the tutorial to add those instructions to the earlier part as well.
As for the developer command prompt; what's happening there is that you're getting the x86 version of the command prompt (which assumes you're developing for a 32-bit environment), to get the x64 version you want to launch the "x64 Native Tools Command Prompt for VS 2017" instead: https://docs.microsoft.com/en-us/cpp/build/how-to-enable-a-64-bit-visual-cpp-toolset-on-the-command-line?view=msvc-160 I'll update the tutorial regarding this as well.
Thanks for the report!
hasnogaems commentedon Dec 17, 2024
Same issue here
Will try solutions from thread
pm100 commentedon Mar 19, 2025
Yup the tutorial still has a bare link command (and no call to CRT_INIT
Had to come here and pull the linker flags from the build.bat script