News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests

Main Menu

Error while Building the program

Started by emerald-monk, January 09, 2020, 04:47:17 AM

Previous topic - Next topic

emerald-monk

Hi!!
I'm new to assembly language and I'm trying to build a small program that prints "A" character. However when I'm trying to build the code from Project >> Build All, I'm getting the following error:

LINK : error LNK2001: unresolved external symbol _main
temp.exe : fatal error LNK1120: 1 unresolved externals
Link error...

Here is my piece of code:
dosseg
.model small
.stack 100h
.data
.code
main proc
    mov dl, 'A'
    mov ah, 2
    int 21h
    mov ah, 4ch
    int 21h
    main endp
end Main

can anyone help me on how to resolve this please??

jj2007

It works fine over here. What kind of error messages do you get?

Follow these steps:
- extract the attached file to \Masm32\BldRun16.bat
- modify \Masm32\menus.ini:
...
Build+Run 16-bit,\MASM32\BldRun16.bat "{b}"

[&Tools]

- open your source in qEditor, save as test.asm (for example) and click Project/Build+Run 16-bit

If you get an error about incompatibility etc, it means you have a 64-bit OS that won't run 16-bit programs. Go to this page and download Binaries and Source Codes (i86/i286/i386/i486)

Since that page right now has a problem, you may also use the older attached version. Extract to \Masm32\bin\msdos.exe

mineiro

hello sir emerald-monk;
This can be solved by some ways, but I prefer talk to you do that by hands.
I'm not sure what IDE you're using, so, the assemble and link command line are hidden. Do this by hands instead of "build all".

If you're impatience, you can try insert before main proc the line below:
public main

Other thing you can try is remove "main proc" and "endp" and insert in the place of "main proc" the line below:
main:

Can you see that the error link "renamed" your "main" to "_main"? This is probably because the linker is trying to link that as a "c" style in easy words, or ... .
This code is done to ms-dos 16 bits, by default I'm assuming your IDE is trying to assemble and link that to 32 bits.

ps: try what sir jj2007 posted previously.
Good job.
I'd rather be this ambulant metamorphosis than to have that old opinion about everything

aw27

\masm32\bin\ML6 -c test.asm
Microsoft (R) Macro Assembler Version 6.14.8444
Copyright (C) Microsoft Corp 1981-1997.  All rights reserved.

Assembling: test.asm

\masm32\bin\link16 test.obj, test.exe,0,0,nul.def

Microsoft (R) Segmented Executable Linker  Version 5.60.339 Dec  5 1994
Copyright (C) Microsoft Corp 1984-1993.  All rights reserved.


emerald-monk

Hi!! Everyone, i'm using IDE from www.masm32.com/download.htm

I'm trying to fix the problem but i can't seem to find the settings/configuration/preferences page where I can check what the problem is.

Thanks & Regards

aw27

The IDE is not important, people in the DOS era used Edlin or Edit or even con

con is the easiest here.

c:\type con > test.asm
dosseg
.model small
.stack 100h
.data
.code
main proc
    mov dl, 'A'
    mov ah, 2
    int 21h
    mov ah, 4ch
    int 21h
    main endp
end Main
^Z

Build with the tools, as explained above.

What you don't know is the syntax of the tools needed to build the program and can't figure out from the supplied examples. This is the serious problem.

mineiro

AW, I remember echo too to redirect to a file.
"Programming in extreme conditions" article by Kalmykov.b52
We can also do that by using Paint Shop Pro, Photoshop, hexadecimal colors, debug, ... .

emerald-monk;
You need do that by hands.
Have archieved old board with tons of examples, a lot of command lines to be used in 16 bits DOS programming.
Check your assembler and link version.
http://www.masmforum.com/board/index.php
I'd rather be this ambulant metamorphosis than to have that old opinion about everything

aw27

Quote
AW, I remember echo too to redirect to a file.
"Programming in extreme conditions" article by Kalmykov.b52
We can also do that by using Paint Shop Pro, Photoshop, hexadecimal colors, debug, ... .

@mineiro  :biggrin:

jj2007

Quote from: emerald-monk on January 09, 2020, 10:26:06 PM
I'm trying to fix the problem but i can't seem to find the settings/configuration/preferences page where I can check what the problem is.

Just read my post above carefully, it will solve your problem.

TimoVJL

If you know something about C, check this toy.
TLIDE

ccpath: \masm32\bin\ml.exe
link: \masm32\bin\link16.exe
May the source be with you