I am learning assembly language programming using MASM32, and seem to be doing OK so far (I have a little programming knowledge in other languages), but I am getting a bit confused about libraries.
I understand the general concepts of include, includelib, static and dynamic libraries, but what do I actually need to put into my source code?
There seems to be so many .inc and .lib files mentioned in various MASM32-related texts, but with no real explanation of their actual usage, and of which ones you need to include when, and what for. Do I actually need windows.inc in all my programs? If I want to use the API MessageBox, which includelib should I have, and which .inc do I need to include as well? If I wish to invoke it, do I need something else as well?
Is there a simple, matter-of-fact guide to libraries in assembler and MASM32 anywhere?

Any help greatly appreciated.
Posted on 2001-07-30 05:48:31 by Unregistered
Libraries are a mess, and are likely to stay that way.

The only "simple, matter-of-fact guide to libraries" that exists is MSDN, and I wouldn't call that simple. However, in the edition I use (from MSVC 6, came on CD), each API function listing ends with which dll contains it.

So if you use API function XYZ, which is in library ABC, you need to include the .inc and the .lib from ABC in your program.

The .inc file declares the procedure prototypes so the compiler can check your invokes. The library gives the linker information on how to build the jump table from your code to the linked object.
Posted on 2001-07-30 06:52:54 by Ernie
You need something like the WIN32API.HLP file, or the "WIN32 programming API bible" book. These tell you which library is needed for every API function. :)
Posted on 2001-07-30 06:55:46 by S/390
Firstly I'd acquire the Win32 api help file...it has details of the core API Functions, and constants eventually you'll want to acquire the multimedia, winsock, resource,etc help files.
Win32, multimedia and winsock help files all contain info on their respective areas of the Win32 API.

You don't have to include Windows.inc in your source files...as long as you've defined the API constants used by your program. Using Windows.inc simplifies this, it'll contain most of what you'lll need.

oh just a tip. If you make a include file called standard.inc and add the following lines to it:

include \masm32\include\windows.inc
include \masm32\include\user32.inc
include \masm32\include\GDI32.inc
include \masm32\include\kernel32.inc
include \masm32\include\masm32.inc ;masm32 library

includelib \masm32\lib\user32.lib
includelib \masm32\lib\GDI32.lib
includelib \masm32\lib\kernel32.lib
includelib \masm32\lib\masm32.lib ;masm32 library

Then you'll be covered for the core API functions by including standard.inc in your source file. You can add other include/includelib as you need them.

to use the API function MessageBox
you'll need:

include \masm32\include\windows.inc ;has defines for MessageBox constants, which determine the nature of the resulting dialog, such as MB_OK, MB_ICONERROR etc.

include \masm32\include\user32.inc; Function prototype for MessageBox allows the use of: invoke MessageBox,p1,p2,p3,p4

includelib \masm32\lib\user32.lib;contains locations of functions and other "fix up " information for USER32.DLL

I hope that's of some Help

The Martial
Posted on 2001-07-30 07:54:37 by MArtial_Code