0

I can't get an assembly language program used as an example in the book Guide to Assembly Language: A Concise Introduction by James T. Streib to run. I'm using Visual Studio 2015. I'm following these instructions: http://www.jtstreib.com/VStudio13.html I've gone through all the steps as described in that guide, but the program still won't run. Trying to assemble it, I get this error:

LNK2019 unresolved external symbol _printf referenced in function _main
LNK1120 1 unresolved externals

The source code:

.386
.model flat, c
.stack 100h

printf proto arg:ptr byte

.data
    msg byte "Hello World!", 0Ah, 00h

.code
main proc
    invoke printf, addr msg
    ret
main endp
end
  • This question may be related to SO question http://stackoverflow.com/questions/33721059/call-c-standard-library-function-from-asm-in-visual-studio (It might even be a duplicate). I provided a couple of answers to resolve the other question that may apply here. – Michael Petch Jun 08 '16 at 12:24
  • I don't see `Visual Studio 2013 (v120)` or anything like that listed in `Platform Toolset`. The only thing I got is `Visual Studio 2015 (v140)` and `Visual Studio 2015 - Windows XP (v140_xp)` –  Jun 08 '16 at 12:27
  • Just curious, do you happen to be using VS 2015 Express edition? – Michael Petch Jun 08 '16 at 12:32
  • Yes. Community Edition. By the way, the second answer is not working for me either. I get a bunch of errors like this: `LINK : warning LNK4098: defaultlib 'libcmt.lib' conflicts with use of other libs; use /NODEFAULTLIB:library` –  Jun 08 '16 at 12:34
  • I tweaked something and now it compiles, but crashes. –  Jun 08 '16 at 12:36
  • Yep, it does. I just checked. –  Jun 08 '16 at 12:44
  • I have no idea what mode I'm using. –  Jun 08 '16 at 12:47
  • Where exactly do I need to add this /NODEFAULTLIB:library ? Though, that's just a warning. –  Jun 08 '16 at 12:48
  • The file compiles as a 32-bit application fine save only for a bunch of warnings, but crashes on me every time I try to run it. As a 64-bit application, it doesn't compile. The assembler throws all sorts of errors at me. –  Jun 08 '16 at 22:26
  • It also appears that if you Install (Everything) the installer has an option for "Windows 8.1 And Windows Phone 8/8.1" which has the option to install the "Tools and Windows SDK". I believe that includes the VS2013 toolset. – Michael Petch Jun 09 '16 at 01:32
  • 1
    I don't know what happened, but I've been tweaking things here and there and now everything seems to work just fine (with those four include library lines included, of course). –  Jun 09 '16 at 02:08
  • Glad you got it going! Had to be something in the environment or project interfering (that you fixed). Very hard to know. In a normal environment it should just work. – Michael Petch Jun 09 '16 at 02:14

0 Answers0