When I compile the following code with JWasm, I get the same result, no matter if I use includelib or not. If that's the case, what's the advantages of using includelib?
...
include c:\masm32\include\windows.inc
include c:\masm32\include\user32.inc
include c:\masm32\include\kernel32.inc
; includelib c:\masm32\lib\user32.lib
; includelib c:\masm32\lib\kernel32.lib
...
includelib informs the linker in which library's to search for unresolved symbols/functions - in case of user/kernel32.lib this are dynamic linked functions. As long as you don't use any function from the corresponding DLL, it doesn't mater if you specify it or not.
Here's the complete code (it's from the example folder)
.586
.model flat, stdcall
option casemap :none ; case sensitive
include c:\masm32\include\windows.inc
include c:\masm32\include\user32.inc
include c:\masm32\include\kernel32.inc
; includelib c:\masm32\lib\user32.lib
; includelib c:\masm32\lib\kernel32.lib
.code
start:
jmp @F
szDlgTitle db "Test Window", 0
szMsg db "It Works! ", 0
@@:
invoke MessageBox,
0,
ADDR szMsg,
ADDR szDlgTitle,
MB_OK
invoke ExitProcess,
0
end start
Looking with a disassembler, I see this:
+++++++++++++++++++ IMPORT MODULE DETAILS +++++++++++++++++
Import Module 001: KERNEL32.DLL
Addr:00002074 hint(0001) Name: ExitProcess
Import Module 002: USER32.DLL
Addr:00002082 hint(0001) Name: MessageBoxA
This doesn't mean that I'm using function from the dlls I'm not linking to? I assumed that JWasm included automatically the necessary references, but, in this case, why should I manually use includelib?
how do you call the linker? I've not heard about such an feature of jwasm.
Quote from: qWord on February 23, 2010, 07:22:23 PMhow do you call the linker? I've not heard about such an feature of jwasm.
jwasm index.asm
wlink system nt file index.obj
Quote from: Sergiu FUNIERU on February 23, 2010, 06:31:52 PM
When I compile the following code with JWasm, I get the same result, no matter if I use includelib or not. If that's the case, what's the advantages of using includelib?
Sergiu,
includelib user32.lib (for example) means "give assembler & linker a chance to use the functions of user32.dll". Whether they actually need it is of minor importance. Many here in the forum use this:
include \masm32\include\masm32rt.inc
.code
start: MsgBox 0, "Hello World", "Masm is easy:", MB_OK
invoke ExitProcess, 0
end start
masm32rt.inc includes a bunch of typically used libraries, plus the macros like print, MsgBox etc., and certain standard settings. Just open the file in an editor to see what it does.
Purists prefer a long list of tailored include/includelib statements, sometimes with the argument that ml.exe has to work unnecessarily hard if it loads so many unused libraries. Timings show, though, that it slows assembly down by only a handful of milliseconds.
Hi Sergiu,
Jeremy Gordon's linker Golink does not require the usage of import libraries. It's enough to specify the DLLs :
\Jwasm\Jwasm -c -coff Dlgbox.asm
\Goasm\Gorc /r Rsrc.rc
\Goasm\Golink /entry _start Dlgbox.obj Rsrc.res kernel32.dll user32.dll
I understand why some people will use one big include file, while other will list individually what to link to. But I didn't use ANY includelib in my asm file, yet it created a valid exe.
I suppose this happened due to the way that the obj file was linked, but, in this case, why using includelib at all when the linker is smart enough to figure out what to link?
Or only wlink is smart enough to do that and other linkers need to be told explicitly?
Off topic:
Please don't consider me rude, but either you use my correct first name (Sergiu) or not call me by name at all. If you call me Sergui or Sergio instead of Sergiu, someone who will read your post will propagate the wrong version. This went that far that when I asked for a credit card, I said "It's Sergio, but the last letter is "U"". Guess what? I received my credit card with my name written as Sergiou. It was my mistake, but I didn't think of that combination. :bg
you've had a troubled life, Sergiu :P
that's odd, because you don't look like a criminal or anything
maybe you walk like a criminal - lol
i once bought a pick-up truck and the DMV put a "5" in the VIN instead of an "S"
my title did not match my truck
boy - that was hard to get fixed
Quote from: dedndave on February 23, 2010, 08:26:08 PMyou've had a troubled life, Sergiu :P
Tell me about it!
Quote from: dedndave on February 23, 2010, 08:26:08 PMthat's odd, because you don't look like a criminal or anything
Except for being skinhead. I cut my hair to avoid pulling it while learning asm.
Quote from: dedndave on February 23, 2010, 08:26:08 PMmaybe you walk like a criminal - lol
No, I sit on the chair all day, trying to do killer programs.
Quote from: dedndave on February 23, 2010, 08:26:08 PMi once bought a pick-up truck and the DMV put a "5" in the VIN instead of an "S"my title did not match my truck boy - that was hard to get fixed
Yes, but it was once. I have this problem with my name several times a day, in several forums.
I have the same problem with the asm programs I try to understand : it seems there are too many letters in them, which I don't know why are there.
Actually Sergiu, you look a lot like my CO when I was in the military.....
http://www.facebook.com/photo.php?pid=72908&id=100000283084289
The guy in the bottom left
Try being named Wry.
I'm seriously thinking about launching a new website regarding my first name. Of course, I'll buy all the misspellings. :bg
Quote from: WryBugz on February 23, 2010, 10:25:49 PMTry being named Wry.
I'm not talking about mnemonics :wink
It's first time I heard this name, but it's easier to remember. I mean it.
Quote from: Gunner on February 23, 2010, 10:19:37 PM
Actually Sergiu, you look a lot like my CO when I was in the military.....
http://www.facebook.com/photo.php?pid=72908&id=100000283084289
The guy in the bottom left
It seems that so many people looked at my picture that will be a good idea to post the question on my forehead. I haven't figure out yet how to synchronize the picture with the topic.
My poor includelib question : we left it back in the dust...
i think that is a matter of static and dynamic linking, Sergiu
i am not yet that familiar with JWasm, so i'll leave it to those who are
Quote from: Sergiu FUNIERU on February 23, 2010, 07:46:57 PM
wlink system nt file index.obj
How did you get rid of
Warning! W1107: undefined system name: nt ?
By the way:
include c:\masm32\include\windows.inc is a bad habit, since many members have installed Masm32 on another drive. Please use
include \masm32\include\windows.inc
Quote from: jj2007 on February 23, 2010, 11:51:15 PMHow did you get rid of Warning! W1107: undefined system name: nt ?
I didn't see that error message. I attached below what I see when I assemble the index.asm file. I use Windows Vista, Home Premium, in case it makes a difference.
(http://lunlun.ro/masm32/pictures/OutpPut_000001.png)
Quote from: jj2007 on February 23, 2010, 11:51:15 PMBy the way: include c:\masm32\include\windows.inc is a bad habit, since many members have installed Masm32 on another drive. Please use include \masm32\include\windows.inc
I agree that is a bad habit.
I installed JWasm on the drive C. I create a separate virtual drive for each language I'm working with.
For instance, issuing this command:
subst y: c:\asm_source
I have a letter reserved only to asm.
I do this because I work on a single project at a time and for me is simpler this way. If I use \masm32 instead of c:\masm32, I will get errors, because the source is on drive y, and there is nothing in the y:\masm32 folder.
I'm planning to do this:
set include_path = c:\masm32\include
include %include_path%\windows.inc
I know that the above syntax is not the right one, and I was planning to ask that question in a separate thread.
Quote from: Sergiu FUNIERU on February 24, 2010, 12:16:37 AM
Quote from: jj2007 on February 23, 2010, 11:51:15 PMHow did you get rid of Warning! W1107: undefined system name: nt ?
I didn't see that error message. I attached below what I see when I assemble the index.asm file. I use Windows Vista, Home Premium, in case it makes a difference.
Thanks, Sergiu. In the meantime, I found out that there is a file \masm32\bin\wlink.lnk containing the necessary paths. The lnk extension is quite misleading, but it actually opens in a test editor.
Re include paths, it is assumed that your asm sources reside on the same drive as your masm32 installation - hence no need for a drive letter, and no need for environment variables. Not sticking to this rule means reducing the number of responses to your posts.
Quote from: jj2007 on February 24, 2010, 12:39:47 AMThanks, Sergiu.
I thank you.
Quote from: jj2007 on February 24, 2010, 12:39:47 AMRe include paths, it is assumed that your asm sources reside on the same drive as your masm32 installation - hence no need for a drive letter, and no need for environment variables. Not sticking to this rule means reducing the number of responses to your posts.
My includelib statements are all disabled in the index.asm I posted. Yet, it still works.
By the way, 1 minute ago I tried with relative path, running all from c: drive. The result was the same.
Quote from: Sergiu FUNIERU on February 24, 2010, 12:58:15 AM
My includelib statements are all disabled in the index.asm I posted. Yet, it still works.
It works for this particular case because wlink.lnk contains the info about the libraries to include. Masm needs the includelib statements but does not need an extra configuration file - in my opinion the better way.
Quotesystem begin nt
option osname='Windows NT character-mode'
libpath \masm32\lib
library kernel32,user32,gdi32,msvcrt.lib
op stack=0x40000
format windows nt ^
runtime console=4.0
end
Quote from: jj2007 on February 24, 2010, 12:39:47 AMIn the meantime, I found out that there is a file \masm32\bin\wlink.lnk containing the necessary paths. The lnk extension is quite misleading, but it actually opens in a test editor.
I believe that the lnk extension chosen for WLink's configuration files is an unfortunate coincidence with the Windows's extension for shortcuts.
However, the lnk extension for your configuration file is assumed if you don't specify one. So, you can use a MySettings.txt file if you wish, which you can easily open in a plain text editor.
I found this in the WLink manual:
The default name of the linker directive file (wlink.lnk) can be overridden by the WLINK_LNK environment variable. If the specified file can't be opened, the default file name will be used. For example, if the WLINK_LNK environment variable is defined as follows
set WLINK_LNK=my.lnk
then the Open Watcom Linker will attempt to use a my.lnk directive file, and if that file cannot be opened, the linker will revert to using the default wlink.lnk file.[/i]
Quote from: jj2007 on February 24, 2010, 12:39:47 AMIn the meantime, I found out that there is a file \masm32\bin\wlink.lnk containing the necessary paths. The lnk extension is quite misleading, but it actually opens in a test editor.
I believe that the lnk extension chosen for WLink's configuration files is an unfortunate coincidence with the Windows's extension for shortcuts.
However, the lnk extension for your configuration file is assumed if you don't specify one. So, you can use a MySettings.txt file if you wish, which you can easily open in a plain text editor.
I found this in the WLink manual:
The default name of the linker directive file (wlink.lnk) can be overridden by the WLINK_LNK environment variable. If the specified file can't be opened, the default file name will be used. For example, if the WLINK_LNK environment variable is defined as follows set WLINK_LNK=my.lnk
then the Open Watcom Linker will attempt to use a my.lnk directive file, and if that file cannot be opened, the linker will revert to using the default wlink.lnk file.You also can import the file from the attached archive and run it. It will add a "Edit with NotePad" option in the right click menu for .lnk files. Of course, the .reg file from the archive can be customized, that is you can use your proffered text editor instead of NotePad.