The MASM Forum

General => The Campus => Topic started by: ColbyCoffman on February 21, 2022, 04:32:38 AM

Title: Unresolved External Symbol for Basic Subroutine???
Post by: ColbyCoffman on February 21, 2022, 04:32:38 AM
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.
Title: Re: Unresolved External Symbol for Basic Subroutine???
Post by: nidud on February 21, 2022, 04:41:09 AM
deleted
Title: Re: Unresolved External Symbol for Basic Subroutine???
Post by: ColbyCoffman on February 21, 2022, 04:43:39 AM
I am facepalming myself right now. Thank you so much nidud  :bgrin:
Title: Re: Unresolved External Symbol for Basic Subroutine???
Post by: Vortex on February 21, 2022, 04:53:05 AM
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