News:

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

Main Menu

Unresolved External Symbol for Basic Subroutine???

Started by ColbyCoffman, February 21, 2022, 04:32:38 AM

Previous topic - Next topic

ColbyCoffman

Hello, first I would like to say I am new here and I am very sorry if I am posting in the wrong place but I am new to MASM and I am pulling my hair out. Here is the basic code I'm Having issues with.

.386
.model flat, stdcall
.stack 4096

sample PROTO
ExitProcess PROTO, dwExitCode:DWORD

.code
main PROC
   CALL sample
   INVOKE ExitProcess, 0
main ENDP
END main

sample PROC
   ret
sample ENDP

Seems fine to me, except when I build it  I get a 1>Source.obj : error LNK2019: unresolved external symbol _sample@0 referenced in function _main@0. Error. I beleive this should only happen when i call a subroutine that is not properly linked from an external file, but this subroutine is in THE SAME FILE. Maybe I have configured something wrong in visual studios. Any help would be appreciated.

nidud

#1
deleted

ColbyCoffman

I am facepalming myself right now. Thank you so much nidud  :bgrin:

Vortex

Hi Colby,

Here is another example for you :

include \masm32\include\masm32rt.inc

sample  PROTO :DWORD     

.data

title1  db 'Hello',0
mymsg   db 'This is a test.',0

.code

main PROC

    invoke  sample,ADDR mymsg
   
    invoke  ExitProcess,0

main ENDP

sample  PROC message:DWORD

    invoke  MessageBox,0,message,\
            ADDR title1,MB_OK

    ret

sample  ENDP

END main