The MASM Forum

General => The Campus => Topic started by: Victor43 on July 25, 2012, 11:30:45 AM

Title: Trying to Display a MessageBox Getting Error
Post by: Victor43 on July 25, 2012, 11:30:45 AM
Hello I'm working on a messagebox program but running into linking errors. Here is the code: I am using MASM from WinASM. It does not make any difference if using the full path to the library.

includelib user32.lib
includelib kernel32.lib
include user32.inc
include kernel32.inc

.MODEL small, stdcall

.STACK 100H
.DATA

Text1 DB  'Hello World!', 0
      Text2 DB  'Message Title', 0

.386  
.CODE

main  PROC

mov ax,@data ; Get the address of the data segment
mov ds,ax ; Set the DS segment

push 0
push offset Text1
push offset Text2
push 0

call MessageBox

main ENDP
END    main


The linking erors that I am getting are the follows:

C:\masm32\bin\Link16 @"E:\DEVS\Projects\Assembly\DosExe\link.war"

Microsoft (R) Segmented Executable Linker  Version 5.60.339 Dec  5 1994
Copyright (C) Microsoft Corp 1984-1993.  All rights reserved.

Object Modules [.obj]: E:\DEVS\Projects\Assembly\DosExe\DosExeV2.objj
LINK : warning L4051: user32.lib : cannot find library
Enter new file spec: LINK : warning L4051: kernel32.lib : cannot find library
Enter new file spec:
E:\DEVS\Projects\Assembly\DosExe\DosExeV2.obj(E:\DEVS\Projects\Assembly\DosExe\DosExeV2.asm) : error L2029: '_MessageBoxA@16' : unresolved external

There was 1 error detected

Make finished. 2 error(s) occured.
Title: Re: Trying to Display a MessageBox Getting Error
Post by: hutch-- on July 25, 2012, 01:19:59 PM
You are using the wrong linker, use LINK.EXE, LINK16 is for DOS programs. Remove the .STACK line, change model to FLAT then include WINDOWS.INC first with the include files.
Title: Re: Trying to Display a MessageBox Getting Error
Post by: Victor43 on July 25, 2012, 02:26:04 PM
Quote from: hutch-- on July 25, 2012, 01:19:59 PM
You are using the wrong linker, use LINK.EXE, LINK16 is for DOS programs. Remove the .STACK line, change model to FLAT then include WINDOWS.INC first with the include files.

Its working now thank you.
Title: Re: Trying to Display a MessageBox Getting Error
Post by: dedndave on July 25, 2012, 09:24:51 PM
...and you don't need to mess with the DS register   :P