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
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?
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
Did you declare it public? Try this:
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
; -------- 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
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?
JCL, b.asm and a.asm is a make up. i don't know how to say this, but think!
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
Oh. I see it now! Thanx, Mirno. By the way, do u have an icq account, Mirno?