News:

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

Using a Resource File

Started by raleeper, October 26, 2009, 03:09:24 PM

Previous topic - Next topic

raleeper

I think this is really elementary and I'm embarassed to admit that I can't figure it out.

I'm trying to add a menu to my app and I'm following Iczelion's Tutorial 8: Menu.  Everything seems pretty clear, except getting link.exe to accept the resource file.

Iczelion gives:

makefile
NAME=menu
$(NAME).exe: $(NAME).obj $(NAME).res
        Link /SUBSYSTEM:WINDOWS /LIBPATH:c:\masm32\lib $(NAME).obj $(NAME).res
$(NAME).res: $(NAME).rc
        rc $(NAME).rc
$(NAME).obj: $(NAME).asm
        ml /c /coff /Cp $(NAME).asm

which is Greek to me.  I suppose I ought to learn to use makefiles, but I never have.

I assemble and link using a batch file, in particular:

C:\AW.BAT

g:
cd lfw
g:\prog\masm32\bin\ml /c /coff /Cp /Fl /W2 /Zi g:\lfw\lfw.asm >errs
if errorlevel 1 goto erfc
g:\prog\masm32\bin\link /SUBSYSTEM:WINDOWS /LIBPATH:g:\prog\masm32\lib /DEBUG /DEBUGTYPE:CV lfw.obj >>errs
if errorlevel 1 goto erfc
cd\
c:
exit
:erfc
type errs
pause
cd\
c:


I realize this contains some redundancies and inelegances, but it works ok.

But what can I add to get link to use my resource file, menu.rc?


devgeek

g:
cd lfw
g:\prog\masm32\bin\ml /c /coff /Cp /Fl /W2 /Zi g:\lfw\lfw.asm >errs
if errorlevel 1 goto erfc
g:\prog\masm32\bin\rc lfw.rc >> errs
if errorlevel 1 goto erfc
g:\prog\masm32\bin\link /SUBSYSTEM:WINDOWS /LIBPATH:g:\prog\masm32\lib /DEBUG /DEBUGTYPE:CV lfw.obj lfw.res >>errs
if errorlevel 1 goto erfc
cd\
c:
exit
:erfc
type errs
pause
cd\
c:

MichaelW

raleeper,

There is more than one way to do this, depending on the tools you use. If you look in masm32\bin\bldall.bat, near the top you will see two lines:

\masm32\bin\rc /v rsrc.rc
\masm32\bin\cvtres /machine:ix86 rsrc.res

The first line compiles the resource script to rscr.res, and the second converts rsrc.res to the object file rsrc.obj, which will be passed to the linker in the linking stage. Note that the batch files that deal with resource scripts expect the resource script to be named rsrc.rc, to avoid name conflicts with the object file created from the .asm source.
eschew obfuscation

raleeper

Thank you, devgeek.

I did not realize rc was an executable, or I would have found G:\Prog\masm32\bin\rc.hlp.

    (Or maybe not, given the degree of my obtuseness so far [3:52 edt])

Thanks again!

Robert

Update 3:17

Thamks also, MichaelW.

I expect your post will be very helpful also.