| | |
Win32 NASM compile probs with nasmw + lcclnk
![]() |
•
•
Join Date: Feb 2009
Posts: 5
Reputation:
Solved Threads: 0
I'm trying to compile an example nasm program I downloaded for windows. But I can't get it to compile.
When I compile it with that, the first part of it goes fine, it's when I use lcclnk to link it I get these error messages:
Here's the first part of my code:
I'm determined to get this working, as I really want to start coding in NASM for windows.
Thanks in advance.
Assembly Syntax (Toggle Plain Text)
C:\nasm-2.06rc1\nasmw -f win32 example.asm C:\lcc\bin\lcclnk -s -subsystem windows example.obj
When I compile it with that, the first part of it goes fine, it's when I use lcclnk to link it I get these error messages:
Assembly Syntax (Toggle Plain Text)
C:\Documents and Settings\Administrator\Desktop\NASM\DEMO>C:\lcc\bin\lcclnk -s - subsystem windows example.obj example.obj .text: undefined reference to 'LoadIconA' example.obj .text: undefined reference to 'LoadCursorA' example.obj .text: undefined reference to 'RegisterClassA' example.obj .text: undefined reference to 'GetLastError' example.obj .text: undefined reference to 'CreateWindowExA' example.obj .text: undefined reference to 'ShowWindow' example.obj .text: undefined reference to 'UpdateWindow' example.obj .text: undefined reference to 'GetMessageA' example.obj .text: undefined reference to 'TranslateMessage' example.obj .text: undefined reference to 'DispatchMessageA' example.obj .text: undefined reference to 'ExitProcess' example.obj .text: undefined reference to 'DefWindowProcA' example.obj .text: undefined reference to 'PostQuitMessage' example.obj .text: undefined reference to 'BeginPaint' example.obj .text: undefined reference to 'DrawTextA' example.obj .text: undefined reference to 'EndPaint'
Here's the first part of my code:
Assembly Syntax (Toggle Plain Text)
%include "C:\Documents and Settings\Administrator\Desktop\NASM\DEMO\win32n.inc" extern RegisterClassA extern CreateWindowExA extern CreateWindow extern ShowWindow extern UpdateWindow extern GetMessageA extern TranslateMessage extern DispatchMessageA extern DefWindowProcA extern ExitProcess extern MessageBeep extern GetLastError extern LoadIconA extern LoadCursorA extern PostQuitMessage extern BeginPaint extern EndPaint extern DrawTextA global _WinMain@16 SEGMENT .text USE32 class=code _WinMain@16: %define ebp_hInstance ebp+8 ; handle of current instance %define ebp_hPrevInstance ebp+0ch ; handle of previous instance %define ebp_lpszCmdLine ebp+10h ; pointer to command line %define ebp_nCmdShow ebp+14h ; show state of window
I'm determined to get this working, as I really want to start coding in NASM for windows.
Thanks in advance.
•
•
Join Date: Feb 2009
Posts: 5
Reputation:
Solved Threads: 0
"Does the link know where and to include C headers etc...." Good point, how does one go about doing that? I tried linking it with gcc, but I still get the same error message.
•
•
Join Date: Feb 2009
Posts: 5
Reputation:
Solved Threads: 0
•
•
•
•
I'd recommend a read of Narue's tutorial, its a few posts down and is a brillaint intro to NASM on windows
I added this:
Assembly Syntax (Toggle Plain Text)
import MessageBoxA user32.dll
Still though, it's still pissing me about. There's so many annoying little things that don't work, yet should.
Assembly Syntax (Toggle Plain Text)
[extern MessageBoxA] import MessageBoxA user32.dll [global _main] [segment .text] _main: push dword szText ; Push param onto stack call box ; Call our function add esp, 4 ; un-bork the stack? ret box: enter 0,0 mov eax, [ebp+8] ; Pull first param off stack push dword 0 ; MB_OK style push dword eax ; First Param push dword eax ; First Param push dword 0 ; HWND parent (NULL) call MessageBoxA xor eax, eax leave ret [segment .data] szText: db 'Hello',0
if I link it with alink, I get this (which doesn't work):
Assembly Syntax (Toggle Plain Text)
C:\nasm-2.06rc1>nasm -o messagebox.obj -f obj messagebox.asm C:\nasm-2.06rc1>c:\alink\alink.exe -oPE -subsys con messagebox.obj ALINK v1.6 (C) Copyright 1998-9 Anthony A.J. Williams. All Rights Reserved Loading file messagebox.obj matched Externs matched ComDefs Generating PE file messagebox.exe Warning, no entry point specified Error writing to file messagebox.exe
If I link it with gcc I get this:
Assembly Syntax (Toggle Plain Text)
C:\nasm-2.06rc1>nasm -o messagebox.obj -f obj messagebox.asm C:\nasm-2.06rc1>c:\MinGW\bin\gcc.exe "C:\nasm-2.06rc1\messagebox.obj" -o size2.e xe C:\nasm-2.06rc1\messagebox.obj: file not recognized: File format not recognized collect2: ld returned 1 exit status
What the hell's going? Is there any documentation online about compiling things in nasm?
Last edited by int_80; Feb 8th, 2009 at 8:35 am.
ASM Syntax (Toggle Plain Text)
[segment .text] global _main _main:
Chris
Knowledge is power -- But experience is everything
![]() |
Other Threads in the Assembly Forum
- Previous Thread: Let's learn assembly!
- Next Thread: pause program
| Thread Tools | Search this Thread |





