News:

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

Adding static code to an import library

Started by Vortex, July 18, 2006, 10:03:22 AM

Previous topic - Next topic

Vortex

Hi friends,

Working on import libraries, I found a very easy way to add static code to an import library. Pelle's librarian polib has the capacity do this :

\masm32\bin\ml /c /coff \masm32\m32lib\StdOut.asm
\masm32\bin\ml /c /coff \masm32\m32lib\StrLen.asm

\masm32\bin\polib /OUT:kernel32.lib /DEF:kernel32.def /MACHINE:IX86
\masm32\bin\polib /OUT:mixed.lib kernel32.lib StdOut.obj StrLen.obj


kernel32.lib is created from kernel32.def and the the library is updated with the addition of two functions from masm32.lib

You use the resulting import library to link your object files :

.386
.model flat, stdcall
option casemap:none

include     \masm32\include\kernel32.inc
include     \masm32\include\masm32.inc

includelib  mixed.lib

.data
message     db 'Hello from mixed lib!',0

.code

start:

invoke      StdOut,ADDR message
invoke      ExitProcess,0

END start

[attachment deleted by admin]

zooba


hutch--

Erol,

This is well done and very useful.  :U
Download site for MASM32      New MASM Forum
https://masm32.com          https://masm32.com/board/index.php

Vortex

Zooba, Hutch,

Thanks for your kind words.

Here is another version of the mixed library. I merged kernel32.lib, user32.lib, gdi32.lib and masm32.lib to build mrt.lib ( Masm run-time library )

\masm32\bin\polib /OUT:kernel32.lib /DEF:def\kernel32.def /MACHINE:IX86
\masm32\bin\polib /OUT:user32.lib /DEF:def\user32.def /MACHINE:IX86
\masm32\bin\polib /OUT:gdi32.lib /DEF:def\gdi32.def /MACHINE:IX86

\masm32\bin\polib /OUT:mrt.lib kernel32.lib user32.lib gdi32.lib \masm32\lib\masm32.lib


A small demo using mrt.lib :

include mrt.inc

.data
message     db 'Hello from mrt.lib!',0

.code

start:

invoke      StdOut,ADDR message
invoke      ExitProcess,0

END start



http://vortex.masmcode.com/files/mrt1.zip

PBrennick

Vortex,
I really like that one!  VERY useful.  We should do something like that.

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

Mark Jones

I was thinking to myself how convenient it would be for a newcomer to just include one file and not have to worry about any other includes... so why not build a master include library?
"To deny our impulses... foolish; to revel in them, chaos." MCJ 2003.08

PBrennick

Mark,
You have read my mind.  Master.inc and Master.lib, coming soon to a project near you!

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

Vortex

Paul, what about renaming the library to GSmrt.lib?

GSmrt.lib = GeneSys master run-time library