LNK 2001 unresolved external symbol _mainCRTStartup MASM

18,382

Solution 1

The other answers were confusing to me so I'll add my solution. In the properties of the project go to

Configuration Properties >> Linker >> Advanced

In Advanced at the top should be Entry Point. Type in main.

Solution 2

I think you may need to specify the entry point manualy since the default symbol for entry on windows isnt _main but the _mainCRTStartup one from your error message. You can specify entry point with /ENTRY:entry_point (some procedure in your assembly) in your linker options.

Solution 3

I know its a bit late - maybe it helps someone - but you should expose main as public, like this

INCLUDE Irvine32.inc

.code
main PROC

mov eax,10000h      ; EAX = 10000h
add eax,40000h      ; EAX = 50000h
sub eax,20000h      ; EAX = 30000h
call DumpRegs

exit
main ENDP

PUBLIC main

END 

Note the second last line

Solution 4

try to include this

includelib  \Irvine\Irvine32.lib
includelib  \Irvine\User32.lib
includelib  \Irvine\kernel32.lib
Share:
18,382
Robert Joseph Dacunto
Author by

Robert Joseph Dacunto

Updated on July 26, 2022

Comments

  • Robert Joseph Dacunto
    Robert Joseph Dacunto almost 2 years

    I'm learning Assembly at my university, and we were given a CD with MASM 615 on it, and we're using the Irvine32 include library. Everything works fine with it on the school computer, but when I try to compile and run the same code on my home computer, I get a link error.

    INCLUDE Irvine32.inc
    
    .code
    main PROC
    
    mov eax,10000h      ; EAX = 10000h
    add eax,40000h      ; EAX = 50000h
    sub eax,20000h      ; EAX = 30000h
    call DumpRegs
    
    exit
    main ENDP
    END main
    

    This code works fine on the PC at school. At home, I go into DOS, set the path to the MASM folder, and do Make32 file.

    This is the error I get:

    LINK32 : error LNK2001: unresolved external symbol _mainCRTStartup
    test.exe : fatal error LNK1120: 1 unresolved externals
    

    The program compiles (I get the .lst, .obj, and .pdb files), but that's it. I'm thinking it's because I have a 64-bit operating system at home, but I have zero idea how to get this up and running in a 64-bit enviornment - the CD or the book has nothing on 64-bit systems. There's only a make16 or make32 .bat file. It's a real bummer because that means I can't do any work at home, unless there's a work around?

  • Anderson Green
    Anderson Green about 11 years
    The link above appears to be broken.
  • Anderson Green
    Anderson Green about 11 years
    I'm still a bit confused: how would you specify the entry point in the assembly language source code?
  • Pyjong
    Pyjong about 11 years
    The link was added by someone else, I have nothing to do with it. The entry point is to be specified as commandline parameter to linker, not in the code.
  • Xantium
    Xantium almost 5 years
    I can confirm that this is the answer. As a side note: it works for nasm as well.