0

I successfully assembled the following code buy I cannot link it.

 TITLE Add and Subtract

;This program adds and subtracts 32-bit integers

INCLUDE Irvine32.inc

.code
main PROC 

mov eax,10000h
add eax,40000h
sub eax,20000h
call DumpRegs

exit
main ENDP
END main

I'm using the following command to link it.

link addsub.obj irvine32.lib kernel32.lib /SUBSYSTEM:CONSOLE /DEBUG

I'm getting the followng error.

irvine32.lib : error LNK2001: unresolved external symbol _MessageBoxA@16 addsub.exe : fatal error LNK1120: 1 unresolved externals

I do not know where to find this MessageBox and link it to the program. Any help?

edit:

So I linked User32.lib into the file with the following command.

link addsub.obj irvine32.lib kernel32.lib user32.lib /SUBSYSTEM:CONSOLE /DEBUG

and got the following error.

LINK: fatal error LNK1000: unknown error consult documentation for technical support options.

What am I supposed to do with that?

rkhb
  • 14,159
  • 7
  • 32
  • 60
  • http://msdn.microsoft.com/en-us/library/windows/desktop/ms645505(v=vs.85).aspx Library User32.lib – ta.speot.is Sep 07 '14 at 04:14
  • 1
    possible duplicate of [What is an undefined reference/unresolved external symbol error and how do I fix it?](http://stackoverflow.com/questions/12573816/what-is-an-undefined-reference-unresolved-external-symbol-error-and-how-do-i-fix) see [this answer](http://stackoverflow.com/a/12574400/902497). – Raymond Chen Sep 07 '14 at 04:18
  • Can you show us the command you use to assemble addsub? – Michael Petch Dec 10 '15 at 19:47

1 Answers1

-2

I do not know where to find this MessageBox and link it to the program. Any help?

I read the fine manual for you:

MessageBox function

Library User32.lib

Community
  • 1
  • 1
ta.speot.is
  • 26,914
  • 8
  • 68
  • 96
  • I added this comment to original post because of bad formatting here. See original post for this comment – goodwinmcd Sep 07 '14 at 04:23
  • It's a different problem so ask another question. On Stack Overflow you're allowed one question per question. I did some light Googling for you and it seems like at least one instance of this problem occurs when trying to mix-and-match object files with different levels of optimisations. I take it you're using http://www.kipirvine.com/asm/gettingStartedVS2012/index.htm so I'd recommend looking at the batch files and making sure that what you're trying to do is the same as what they're doing. – ta.speot.is Sep 07 '14 at 04:30