News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests
NB: Posting URL's See here: Posted URL Change

Main Menu

Error I'm getting in assembler

Started by lbwiley, June 14, 2019, 01:17:34 AM

Previous topic - Next topic

lbwiley

Errors I'm getting: LoganWileyproj3.obj : error LNK2001: unresolved external symbol _ExitProcess@4
LoganWileyproj3.exe : fatal error LNK1120: 1 unresolved externals

Tried a few things
Here's my code:
; LoganWileyproj3.asm - calculated the expression A = (A+B)-(C+D)
INCLUDE Irvine32.inc

.386
.model flat, stdcall
.stack 4096
ExitProcess proto, dwExitCode: dword
.code
main PROC
    ;assign the integer value to registers
    mov eax,150       ; A=EAX=150
    mov ebx,100        ; B=EBX=100
    mov ecx,50          ; C=ECX=50
    mov edx,40         ; D=EDX=40
    ; calculates the expression
    add eax,ebx         ; EAX= (A+B)
    add ecx,edx         ; ECX= (C+D)
    sub eax,ecx         ; EAX= (A+B) - (C+D)
    invoke ExitProcess,0
main ENDP
END MAIN

jj2007

Try to remove the comma after proto

lbwiley

Removing the comma didn't do anything still getting the same error.

tenkey

The linker is not finding kernel32.lib, which is where _ExitProcess@4 resides.
From your coding style, you will need to add kernel32.lib to the list of files the linker needs. You will need the full path name, unless the LIB environment variable is set properly to the .lib directory. The full pathname will depend on your Irvine configuration.

jj2007

This works:
.stack 4096
includelib \masm32\lib\Kernel32.lib


jj2007

Sorry for my previous advice. The PROTO does indeed not need a comma, i.e. the normal syntax is someproc PROTO :DWORD, but that was not the problem. As tenkey wrote, it was the missing Kernel32.lib, which can be included either via includelib:
includelib \masm32\lib\Kernel32.lib
or by adding \masm32\lib\Kernel32.lib to the linker's commandline.

Btw if you have any intention to learn assembly seriously, dump Irvine and use the Masm32 SDK.

aw27

Irvine is not that bad, it teaches how to use Visual Studio with ASM and has a few interesting code samples.
It provides also a kernel32.lib and everything is freely downloadable.

It is always good to know what we are talking about before criticizing.