News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

linker error

Started by cornelius85, December 15, 2009, 08:35:15 PM

Previous topic - Next topic

cornelius85

Playing around with masm proto and proc directives and I encounted this linker error, not much info available on msdn regarding linker error codes
heres a look at the code



include c:\masm32\include\masm32rt.inc
include c:\masm32\include\msvcrt.inc
includelib  c:\masm32\lib\msvcrt.lib


mainproc proto dummy:DWORD

.data


keys   dd 00444d51h,00003657h,0000384Ah,00003244h
       dd 00003453h,00003542h,00324D47h,00005751h
       dd 0000304Eh,00004A48h,00003744h,00003445h
       dd 00384438h,00005042h,00375155h,00005245h
       dd 00364A46h,00005A4Ch,00315344h,00003754h
       dd 00003058h,00304A4Bh,0000504Fh,0000304Ch
       dd 00005150h,00004A44h,00004356h,00004237h
       dd 00005953h,0000514Ch,00003132h,00005436h
       dd 0000444Eh,0000494Bh,00003930h,00005452h
       dd 00005245h,00364A46h,00005A4Ch,00315344h
       dd 00003754h,00003058h,00304A4Bh,0000504Fh
       dd 0000504Fh,0000304Ch,00005150h,00444D51h
       dd 00003657h,0000384Ah,00003244h,00003453h
       dd 00003542h,00324D47h,00005751h,0000304Eh
       dd 00004A48h,00004352h,00315953h,0033514Ch
       dd 00003132h,00005436h,0000444Eh,0000494Bh


user   db     32      dup(?)
alpha  db     "abcdefghijklmnopqrstuvwxyz123456789-0. ABCDEFGHIJKLMNOPQRSTUVWXYZ!^",0
greet  db     "Enter Username: ",0
inproc db     "in proc"
scan   db     "%31s",0


.code

start:

invoke crt_printf, addr greet
invoke crt_scanf, addr scan , addr user
invoke mainproc, addr user
xor eax,eax
invoke crt_exit, eax
end start

mainproc proc dummy:DWORD
crt_printf, addr dummy
ret
local my:DWORD

mainproc endp

end



Don't know where I went wrong when creating the proc and proto stuff, a heads up would be apprechiated

Microsoft (R) Macro Assembler Version 6.14.8444
Copyright (C) Microsoft Corp 1981-1997.  All rights reserved.

Assembling: C:\Users\cornelius\Documents\ASM\c1.asm
Microsoft (R) Incremental Linker Version 5.12.8078
Copyright (C) Microsoft Corp 1992-1998. All rights reserved.

c1.obj : error LNK2001: unresolved external symbol _mainproc@4
c1.exe : fatal error LNK1120: 1 unresolved externals
_
Link error
Press any key to continue . . .

dedndave

Quotemainproc proto dummy:DWORD

try this...

mainproc proto :DWORD


also, i usually specify the entry point in the END directive

        end     start

hutch--

Dave is right here, you must tell the assembler the start and end of the code. Name can be anything you like but commonly the pair "start:" and "end start" is what is used.

This line "local my:DWORD" will generate an error, in MASM you always place LOCAL variables at the start of the proc.
Download site for MASM32      New MASM Forum
https://masm32.com          https://masm32.com/board/index.php

cornelius85

Thanks that definitely helped alot, I'll make a note about that

Vortex

This line :

crt_printf, addr dummy

should be

invoke crt_printf, addr dummy

hutch--

This builds, I don't know what its supposed to do but it builds with no errors.


; -----------------------------------------------

    include \masm32\include\masm32rt.inc

    mainproc proto :DWORD

  .data

  align 4
keys   dd 00444d51h,00003657h,0000384Ah,00003244h
       dd 00003453h,00003542h,00324D47h,00005751h
       dd 0000304Eh,00004A48h,00003744h,00003445h
       dd 00384438h,00005042h,00375155h,00005245h
       dd 00364A46h,00005A4Ch,00315344h,00003754h
       dd 00003058h,00304A4Bh,0000504Fh,0000304Ch
       dd 00005150h,00004A44h,00004356h,00004237h
       dd 00005953h,0000514Ch,00003132h,00005436h
       dd 0000444Eh,0000494Bh,00003930h,00005452h
       dd 00005245h,00364A46h,00005A4Ch,00315344h
       dd 00003754h,00003058h,00304A4Bh,0000504Fh
       dd 0000504Fh,0000304Ch,00005150h,00444D51h
       dd 00003657h,0000384Ah,00003244h,00003453h
       dd 00003542h,00324D47h,00005751h,0000304Eh
       dd 00004A48h,00004352h,00315953h,0033514Ch
       dd 00003132h,00005436h,0000444Eh,0000494Bh

    user   db     32      dup(?)
    alpha  db     "abcdefghijklmnopqrstuvwxyz123456789-0. ABCDEFGHIJKLMNOPQRSTUVWXYZ!^",0
    greet  db     "Enter Username: ",0
    inproc db     "in proc"
    scan   db     "%31s",0

.code

; -----------------------------------------------

start:

    invoke crt_printf, OFFSET greet
    invoke crt_scanf, addr scan , addr user
    invoke mainproc, addr user
    xor eax,eax
    invoke crt_exit, eax

; -----------------------------------------------

mainproc proc arg1:DWORD

    LOCAL my:DWORD

    invoke crt_printf, arg1
    ret

mainproc endp

; -----------------------------------------------

end start
Download site for MASM32      New MASM Forum
https://masm32.com          https://masm32.com/board/index.php