News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests
NB: Posting URL's See here: Posted URL Change

Main Menu

Link Error??

Started by hawkeye62, May 25, 2013, 01:35:36 AM

Previous topic - Next topic

hawkeye62

Well, I am dead in the water. I found masm32>macros>timers.asm which is code that measures the time to complete execution of a block of code inserted in timers.asm. It looks like a good fit for my project. All I need to do is write code to be timed and the grunt work to calculate the time is already there in timers.asm. BUT, I have had no luck making any progress. First, the asm file wouldn't assemble to generate a .obj file.  The error message complained about "END" missing. So, I added "END" as the very last statement and the assembly did proceed to generate a .obj file. BUT link fails with error message: "error LNK2001: unresolved external symbol  - WinMainCRTStartup:.

I have no clue what to do next.

Thanks for any help, Jim

dedndave

in the END directive, you should reference the program entry point

for timers.asm, a processor of .586 or better is required
i select .686p, with mmx and xmm for testing mmx/sse code

notice that a single core is selected at the beginning

we try to adjust the loop count so that each pass takes about 0.5 seconds
that yields fairly repeatable results

assemble as a console app...
;###############################################################################################

        .XCREF
        .NoList
        INCLUDE    \Masm32\Include\Masm32rt.inc
        .686p
        .MMX
        .XMM
        INCLUDE    \Masm32\Macros\Timers.asm
        .List

;###############################################################################################

Loop_Count = 50000000

;###############################################################################################

;        .DATA

;***********************************************************************************************

;        .DATA?

;###############################################################################################

        .CODE

;***********************************************************************************************

_main   PROC

        INVOKE  GetCurrentProcess
        INVOKE  SetProcessAffinityMask,eax,1
        INVOKE  Sleep,750

        mov     ecx,8

Loop00: push    ecx

        counter_begin Loop_Count,HIGH_PRIORITY_CLASS

        ;code to be timed
        mov     eax,100
        xor     edx,edx
        div     eax

        counter_end

        print   str$(eax),32
        pop     ecx
        dec     ecx
        jnz     Loop00

        print   chr$(13,10)
        inkey
        INVOKE  ExitProcess,0

_main   ENDP

;###############################################################################################

        END     _main

hawkeye62

Still no joy in mudville. :(

I did some more work and I have an .asm file that assembles, but fails to link. I get the same link error: "unresolved external symbol _mainCRTStartup". Maybe I am missing a library?

Thanks, Jim

dedndave

it may be that some other version of Link.exe is in the PATH

have you installed the masm32 package ?
how are you assembling the file - with a batch file ?
if so, which one ?

jj2007

Here is a minimalist example:
- Copy code below and save from qEditor as Whatever.asm
- Project, Console Build All
- Run program

Which error messages do you get?

.nolist
include \masm32\include\masm32rt.inc
.xmm
.586
include \masm32\macros\timers.asm   ; download from the Masm32 Laboratory

.code
start:
  invoke Sleep, 100
  counter_begin 100000, HIGH_PRIORITY_CLASS
   push 100
   .Repeat
      test eax, eax
      dec dword ptr [esp]
   .Until Sign?
   pop eax
  counter_end
  inkey str$(eax), 9, "cycles", 13, 10
  exit
   
end start

hawkeye62

Thanks for your reply.

Yes, I installed the masm32 package.

I am assembling from the qeditor menu.

Whatever.asm gives error: "LINK : error LNK2001: unresolved external symbol _mainCRTStartup".

Thanks, Jim


jj2007

The snippet assembles fine on all my machines, it's really well tested.

If you use qEditor, Console build all, and \MASM32\BIN\Bldallc.bat is unchanged, then I can't see any reason why you should have this problem...

Having said that, if I take away the start after end, I get exactly that error.
Maybe you need one or two empty lines after end start ?

Here is my output from qEditor - can you post yours (right-click into console window, select all, hit Enter to copy)?

Microsoft (R) Macro Assembler Version 6.15.8803
Copyright (C) Microsoft Corp 1981-2000.  All rights reserved.

Assembling: C:\Masm32\Whatever.asm

***********
ASCII build
***********

Microsoft (R) Incremental Linker Version 5.12.8078
Copyright (C) Microsoft Corp 1992-1998. All rights reserved.

Volume in drive C has no label.
Volume Serial Number is 4CBE-DFDC

Directory of C:\Masm32

28.05.13  17:30               396 Whatever.asm
28.05.13  17:30             3,072 Whatever.exe
28.05.13  17:30             1,826 Whatever.obj
               3 File(s)          5,294 bytes
               0 Dir(s)  94,605,459,456 bytes free
Press any key to continue . . .

hawkeye62

Thanks for your reply.

Well, I changed three things and Whatever.asm now assembles and links.

The three things:

1. I re-installed masm32

2. I used ml.exe and link.exe as installed vs getting the latest versions from VS

3. I added a blank line after end start

I don't know what fixed the link problem. My output is the same as yours except the assembler version is 6.14.8444

Thanks, Jim

jj2007

Great :t

Now:
1. replace that old ml.exe with JWasm,
2. install Olly to \Masm32\OllyDbg,
3. add /Zi to the assembler commandline,
4. add /debug to the linker commandline,

and you are ready for bigger adventures ;)