Skip to main content
gamedev.net
🔒 Locked

Linking asm + WinAPI

Started by gi-centerprintf 0 replies 1.5k views
Original Post
gi-centerprintf
gi-centerprintf
I have a assembly file library I made for speed, but can''t get it to link to masm32. Here''s the error''s I got...
masm.obj : warning LNK4033: converting object format from OMF to COFF
masm.obj : warning LNK4078: multiple ".text" sections found with different attributes (60220020)
masm.obj : warning LNK4078: multiple ".data" sections found with different attributes (C0220040)
masm32.obj : error LNK2001: unresolved external symbol _test_main
masm32.exe : fatal error LNK1120: 1 unresolved externals
_
Link error
masm.asm + masm.obj = masm code masm32.asm + masm32.obj = masm32 code masm32.exe = output Here''s masm.asm, a very simple assembly file,it was the file library I said above, but I cut out everything
title procedure test_func masm.asm
.model small
.386		;uses x86 specific code

public test_main

.data
.code
test_main            proc
                push ebp
                mov ebp,esp
                ; ya, code goes here

                pop ebp
                ret
test_main            endp
	end
and masm32.asm
...
extrn test_main:proc
...
.code
start:
                 call test_main
                 ...
Topgoro
Topgoro
Hi.

This is actually very basic stuff.

First, the warnings you get indicate the the linker has had to convert formats, and to avoid it, when you assemble your file make sure that somewhere in the command line you include the switch "/coff", in the case shown.

Second, you need to declare the function with the stdcall calling convention. Add the switch "/Gz", in the case shown, somewhere in the command line to get this effect. Alternatively, you can specify the calling convetion using the ".model" directive.

Third, you need to include the "/Cp" switch to make all identifiers case insensitive, or "/Cx" the make the exported identifiers case insensitive. If you do not include any of them, the assembler will export "_TEST_MAIN" (provided the stdcall directive or the "/Gz" switch are used, otherwise the assembler will export "TEST_MAIN", instead) while the linker will be looking for "_test_main".

Also, since you are programming in 32 bits, I believe you should be using the following (and the ".386" directive should be specified before specifying ".model"):

.386
.model flat

Command line example:

ml.exe /c /Cp /coff /Gz /Zi FILE.NAME
/c does not link after compile
/Cp make all identifiers case sensitive
/coff write .OBJ in coff format
/Gz use stdcall for parameter passing
/Zi include code view debug information

Topgoro


Edited by - Topgoro on September 5, 2000 6:51:33 PM

Edited by - Topgoro on September 5, 2000 6:53:24 PM
We emphasize "gotoless" programming in this company, so constructs like "goto hell" are strictly forbidden.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.