6

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?

rkhb
  • 14,159
  • 7
  • 32
  • 60
  • The program Assembles and Links *NOT* compiles. You do not compile anything when using Assembly. Can you post the make file you are using? – Gunner Sep 12 '12 at 01:18
  • Sounds like it's not finding the 'doze equivalent to libc. Do the "set" command to view environment variables. Look for the "LIB" variable. Compare what you see at school and at home. You may need to install a C compiler (at home) to get a C library. The missing variable is in your "C startup code" - the code that calls "_main". Might just need to set the "LIB" variable... – Frank Kotler Sep 12 '12 at 04:40
  • The question is not answerable without the "Make32 file". – rkhb Dec 25 '15 at 18:52

5 Answers5

17

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.

Euri Pinhollow
  • 332
  • 2
  • 17
K.R.
  • 446
  • 4
  • 12
5

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.

legends2k
  • 31,634
  • 25
  • 118
  • 222
Pyjong
  • 3,095
  • 4
  • 32
  • 50
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

Aiden Strydom
  • 1,198
  • 2
  • 14
  • 43
1

try to include this

includelib  \Irvine\Irvine32.lib
includelib  \Irvine\User32.lib
includelib  \Irvine\kernel32.lib
Xantium
  • 11,201
  • 10
  • 62
  • 89
Ramon
  • 11
  • 1
0

If you use MASM32, add /coff parameter.

Example:

ml.exe /c /coff file.asm