News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

a problem when i want to linker...........

Started by kernel19, February 22, 2009, 12:19:54 AM

Previous topic - Next topic

kernel19

hey guys, in this last week i did buy a book about assembler and this book have a exercise to math , but when i try to link , have this problem please help me !!!

The C0de

.386
.model flat,stdcall
.stack 4096
ExitProcess PROTO,dwExitCode:DWORD
DumpRegs PROTO

.code
main PROC

mov eax,10000h
add eax,50000h
sub eax,20000h
call DumpRegs

INVOKE ExitProcess,0
main ENDP
END main


The problem

C:\masm32\bin\Link @"C:\Users\........\Desktop\link.war"

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

/SUBSYSTEM:WINDOWS /RELEASE /VERSION:4.0 "/LIBPATH:C:\masm32\lib" "C:\Users\.......\Desktop\SumaResta.obj" "/OUT:C:\Users\.....\Desktop\SumaResta.exe"
SumaResta.obj : error LNK2001: unresolved external symbol _ExitProcess@4
SumaResta.obj : error LNK2001: unresolved external symbol _DumpRegs@0
C:\Users\........\Desktop\SumaResta.exe : fatal error LNK1120: 2 unresolved externals

Make finished. 2 error(s) occured.



Excuse me by my English .............

MichaelW

I'm guessing that the book is by Kip Irvine. If it is, then the DumpRegs procedure is part of the Irivine32 library (irvine32.lib). Your source looks like the AddSub.asm example from an older version of the book, modified so all of the necessary directives and prototypes are in one file, instead of being included from other files with an INCLUDE directive. In your output, the linker cannot find _ExitProcess@4 and _DumpRegs@0 because it does not know where to look for them. This is a minimal batch file that should be able to assemble, link, and execute your source, assuming that it is run from the directory where the .asm source file is, and that the specified paths are correct:

set lib=c:\masm32\lib;c:\irvine32
set path=c:\masm32\bin;%path%
ml /c /coff %1.asm
pause
Link %1.obj irvine32.lib kernel32.lib /SUBSYSTEM:CONSOLE
pause
%1.exe
pause


Assuming that you named it makeit.bat and that your source is named SumaResta.asm, you would run the batch file from the command line with something like this:

makeit SumaResta
eschew obfuscation

kernel19

Thanks by you answer, but i use  the  winAsm IDE , and i import the library Irvine32.inc all process it´s correct but when i try to linker show me that error message, i don´t not what happened don´t make the .exe file.




INCLUDE Irvine32.inc ; the same directory to project
.code

main PROC

          mov eax, 10000h
          add  eax, 40000h
          sub  eax, 20000h
         
          call DumpRegs

          exit

main ENDP

END main


this it´s other type to write this code with the Irvine32.inc library but show me the same error

PBrennick

If Irvine32.inc is not in the same directory as your source code, you will get an error. You need to make sure the library is locateable in the path or you need to hard-code the directory in the include statement.

Paul
The GeneSys Project is available from:
The Repository or My crappy website

MichaelW

For the source you posted irvine32.inc is not necessary, and including it will not correct the linking problems. If the lib and path statements are correct,  the batch file that I posted will assemble and link your source file without problems. If I change the linker command line in my batch file to:

Link %1.obj /SUBSYSTEM:CONSOLE

Then the linker fails:

C:\masm32\My\Irvine32>Link sumaresta.obj /SUBSYSTEM:CONSOLE
Microsoft (R) Incremental Linker Version 5.12.8078
Copyright (C) Microsoft Corp 1992-1998. All rights reserved.

sumaresta.obj : error LNK2001: unresolved external symbol _ExitProcess@4
sumaresta.obj : error LNK2001: unresolved external symbol _DumpRegs@0
sumaresta.exe : fatal error LNK1120: 2 unresolved externals


I don't use WinAsm so I have no idea what you are doing or how to correct the problem there, but the linker needs to know what libraries to look in.
eschew obfuscation

kernel19

Quote from: PBrennick on February 22, 2009, 06:34:50 AM
If Irvine32.inc is not in the same directory as your source code, you will get an error. You need to make sure the library is locateable in the path or you need to hard-code the directory in the include statement.

Paul

Paul The library Irvine32.inc is in the directory of the project, this library call two librarys, the first it´s VirtualKeys.inc and the second it´s smallWin.inc, me don´t have problem with this librarys Thanks.

Quote from: MichaelW on February 22, 2009, 12:02:40 PM
For the source you posted irvine32.inc is not necessary, and including it will not correct the linking problems. If the lib and path statements are correct,  the batch file that I posted will assemble and link your source file without problems. If I change the linker command line in my batch file to:

Link %1.obj /SUBSYSTEM:CONSOLE

Then the linker fails:

C:\masm32\My\Irvine32>Link sumaresta.obj /SUBSYSTEM:CONSOLE
Microsoft (R) Incremental Linker Version 5.12.8078
Copyright (C) Microsoft Corp 1992-1998. All rights reserved.

sumaresta.obj : error LNK2001: unresolved external symbol _ExitProcess@4
sumaresta.obj : error LNK2001: unresolved external symbol _DumpRegs@0
sumaresta.exe : fatal error LNK1120: 2 unresolved externals


I don't use WinAsm so I have no idea what you are doing or how to correct the problem there, but the linker needs to know what libraries to look in.


MichaelW in this line i show you what it´s my path to linker with the IDE

C:\Program Files\Negatory Assembly Studio 2.0\Assemblers\Bin\LINK.EXE

my OS is WinVista this affect with the path ??

and you can to recomend what it´s you IDE or How i can to programmer in masm in vista OS.

Thanks MichaelW by you answer.

MichaelW

By linker command line, I mean the part of the command line that follows the name of the linker. Your IDE probably provides a way to specify what goes on the ML and LINK command lines, but I have no idea what that might be. I think the easiest solution at this point would be to follow Pauls suggestion and specify the necessary libraries and their location in the asm source, something like this (with the paths modified as necessary):

.386
.model flat,stdcall
.stack 4096

includelib "c:\masm32\lib\kernel32.lib"
includelib "c:\irvine32\irvine32.lib"

ExitProcess PROTO,dwExitCode:DWORD
DumpRegs PROTO

.code
main PROC

    mov eax,10000h
    add eax,50000h
    sub eax,20000h
    call DumpRegs

  INVOKE ExitProcess,0
main ENDP
END main


This will cause ML to place the library names and paths in the object module, so when the linker needs to resolve the references to DumpRegs and ExitProcess, it will know which libraries to look in and where they are located.

eschew obfuscation

kernel19

Man thanks,i try to linker with the includelib but only there is one error less  and this it´s the message now

C:\masm32\bin\Link @"C:\Users\........\Desktop\link.war"

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

/SUBSYSTEM:WINDOWS /RELEASE /VERSION:4.0 "/LIBPATH:C:\masm32\lib" "C:\Users\........\Desktop\addsub.obj" "/OUT:C:\Users\........\Desktop\addsub.exe"
irvine32.lib(Irvine32.obj) : error LNK2001: unresolved external symbol _MessageBoxA@16
C:\Users\........\Desktop\addsub.exe : fatal error LNK1120: 1 unresolved externals

Make finished. 1 error(s) occured.


thanks by you answer..


BogdanOntanu

My "wild" guess would be that you also need to INCLUDELIB yet another library that contains the info about MessageBox(A) ...
Ambition is a lame excuse for the ones not brave enough to be lazy.
http://www.oby.ro

kernel19

i try on many librarys, and now the problem don´t show me, now linker sucessfull, and have the .exe file but this execute file don´t show me nothing
this is the library that me include for make to execute file.


includelib "c:\irvine\User32.Lib"

Thannks by you asnwer

GregL

kernel19,

You can use MSDN to determine the import library for a Windows API.

Quote from: MSDN - MessageBox
Function Information

    Minimum DLL Version           user32.dll
    Header                        Declared in Winuser.h, include Windows.h
    Import library                User32.lib
    Minimum operating systems     Windows 95, Windows NT 3.1
    Unicode                       Implemented as ANSI and Unicode versions.



kernel19

Thanks all, but i follow the instruction in the tutorial that irvine have in his webpage and the IDE that he use it´s visual c++ 2008 and i configure my visual studio and now i can to make the exercise that kip irvine have in his book.

don´t it´s the best form so i need to copy a directory and open that directory make a file with extension .asm and execute and i began my new code that is for the moment meantime i win experience in IA32.

One more time . THANKS BY ALL How answer my cuestions Thanks guys  :U :U