Author Topic: Newbie needing help (2)  (Read 16050 times)

nobody

  • Guest
Newbie needing help (2)
« on: August 05, 2006, 05:34:20 AM »
Sorry to ask again so soon, but I can't quite find a way out.
I tried to compile the source file "demo1.asm" from the nasm32 project:
http://www.asmcommunity.net/projects/nasm32/

the file is this:

%include 'c:\newbie\inc\win32\windows.inc'
%include 'c:\newbie\inc\win32\kernel32.inc'
%include 'c:\newbie\inc\win32\user32.inc'
%include 'c:\newbie\inc\nasm32.inc'

entry    demo1

[section .text]
proc     demo1
    invoke    my_p, dword szContentTwo, dword szTitleTwo
    invoke    MessageBoxA, dword NULL, dword szContent, dword szTitle, dword MB_OK
    invoke    ExitProcess, dword NULL
    ret

endproc

proc     my_p
sz_Content    argd
sz_Title      argd

invoke    MessageBoxA, dword NULL, dword argv(sz_Content), dword argv(sz_Title), dword MB_OK
    ret

endproc

_data
    szTitle:       db   'Demo1', 0x0
    szTitleTwo:    db   'Demo1 Procedure', 0x0
    szContent:     db   'Hello from the Application!', 0x0
    szContentTwo:  db   'Hello from the Procedure!', 0x0

I write in the dos window in the bin subdirectory:

> nasmw -f win32 demo1.asm

and all is ok, then I write

> polink demo1.obj

POLINK: error: unresolved external symbol '_MessageBoxA'
POLINK: error: unresolved external symbol '_ExitProcess'
POLINK: error: unresolved external symbol '_mainCRTStartup'
POLINK: fatal error: 3 unresolved external(s)

It seems it finds the routines but can't execute them, I don't know....

Thank you in advance for any help

Fabrizio newbie

nobody

  • Guest
Re: Newbie needing help (2)
« Reply #1 on: August 05, 2006, 06:45:21 AM »
Hi Fabrizio,

Looks like you need to link against kernel32.lib and user32.lib, too. Take a look at "demo1.bat" to get an idea what the command-line to polink is supposed to look like. You'll need to alter it slightly, since you're installed under "c:\newbie" instead of "c:\nasm32". Something like:

polink /SUBSYSTEM:WINDOWS /ENTRY:main /LIBPATH:c:\newbie\lib demo1.obj kernel32.lib user32.lib

(or re-install under "nasm32" like you're "supposed to" and just use the batch file)

That's untested, but I think that's what the problem is.

Best,
Frank

nobody

  • Guest
Re: Newbie needing help (2)
« Reply #2 on: August 07, 2006, 07:03:29 PM »
the .BAT file works, thank you very much for your help

Fabrizio