I have 2 source files. In the first .data section i have declared a variable dwVar DWORD 0 In the second file I'm accessing it using extrn extrn dwVar:DWORD mov dwVar, 10 Its compiling ok, but giving a linker error Whatzup ... Clark
Posted on 2001-06-25 08:04:00 by Superman_San
Is it because you have not declared it NEAR or FAR? Or is it that there's no need to declare it in 32bit ASM, since we are not talking about segments?
Posted on 2001-06-25 08:11:00 by JCL
No JCL, NEAR and FAR is not necessary in flat memory model. Anyway, I got the solution. The error is solved by declaring dwVar as public. public dwVar dwVar DWORD 0 But I thought all symbols in masm were public by default Clark
Posted on 2001-06-25 08:26:00 by Superman_San
Did you declare it public? Try this:

; -------- a.asm --------
.386
.model flat, stdcall
option casemap:none

include \masm32\include\windows.inc
include \masm32\include\kernel32.inc
include \masm32\include\user32.inc
includelib \masm32\lib\kernel32.lib
includelib \masm32\lib\user32.lib

MyStrChr PROTO :DWORD, :BYTE

extern MyStr:BYTE

.code

main:
  
  invoke MessageBox, 0, ADDR MyStr, 0, MB_OK
  invoke ExitProcess, 0
end main

; -------- b.asm --------
.386
.model flat, stdcall
option casemap:none

PUBLIC MyStr ; <- Makes it available to external objects

.data
MyStr  db "Hello!",0

end
Then assemble & link as follows: 1) \masm32\bin\ml /c /coff a.asm 2) \masm32\bin\ml /c /coff b.asm 3) \masm32\bin\link /SUBSYSTEM:WINDOWS *.obj It should then produce b.exe which when run brings a up a messagebox with "Error" as its title, and "Hello!" as its body. Mirno
Posted on 2001-06-25 08:27:00 by Mirno
So, the problem was not declaring both the data as public, thus not allowing both to link? I remembered that we have to make it public to link 2 pieces of data. By the way, where does b.asm comes from, Mirno? But could i ml /c /coff b.asm when there is no b.asm?
Posted on 2001-06-25 08:45:00 by JCL
JCL, b.asm and a.asm is a make up. i don't know how to say this, but think!
Posted on 2001-06-25 08:49:00 by nop
b.asm was half way down in the code! Here it is again:

; -------- b.asm --------
.386
.model flat, stdcall
option casemap:none

PUBLIC MyStr ; <- Makes it available to external objects

.data
MyStr  db "Hello!",0

end
Mirno
Posted on 2001-06-25 10:04:00 by Mirno
Oh. I see it now! Thanx, Mirno. By the way, do u have an icq account, Mirno?
Posted on 2001-06-26 13:38:00 by JCL