Log in

View Full Version : Linking .res using Borland C++


toolmanx
May 6th, 2007, 16:29
I am using a Borland C++ compiler. I have 3 different resource
compilers to use. Two of them are Brc32 (Brcc32) and GoRC.
I am runing on a AMD with XP.

I have been able to create a .res with either of the above
but I can't get the .res into my .exe either by linking .res
with .obj or by linking .res to .exe.
Brc32 with a -v looks like it works but my program can't
find the data it needs when I run it.

My interest is not to use a Makefile. I want to learn how to
make and use a resource.rc preferably using Brc32 although
GoRC is great.

I am trying to work through a tutorial called "Forgers" tut
on Win32 API. He uses .res extensively in his tut and I
have religeously followed his code examples. My program
won't work unless I put the .res code in the .cpp.

I tried renaming my tut program .rc from resource.rc
to "Short.rc". My .cpp is named "Short.cpp". I thought
possibly [resource] was a reserved name. NOPE!

I read and tried all the hints in the tut about linking
using the Borland linker. Nothing worked.

email me at toolmanx@ij.net if I wasn't clear enough in my
problem description.

LLXX
May 6th, 2007, 20:10
Code:
link [options] progname.obj progname.res [libs]
You can find the M$ 32-bit portable executable linker all over the Internet, needless to say you should search for and obtain it.

blabberer
May 7th, 2007, 02:12
well since you say you are using forgers winprog tutorials and bcc
ill post one example

i assume you have that complete src folder

in the source folder you should be able to find menu_one folder
containing

Code:

05/12/2001 02:46 AM 145 Makefile
02/19/2002 09:38 PM 1,947 menu_one.c
09/16/2001 03:59 PM 4,107 menu_one.dsp
05/03/2002 09:38 PM 49,664 menu_one.exe
09/16/2001 03:51 PM 1,078 menu_one.ico
09/16/2001 03:51 PM 2,236 menu_one.rc
09/16/2001 03:49 PM 643 resource.h


we are going to use them manually so we will delete all the crap thats unneeded

Code:

>del makefile

>del menu_one.dsp

>del menu_one.exe

>dir

05/07/2007 12:27 PM <DIR> .
05/07/2007 12:27 PM <DIR> ..
02/19/2002 09:38 PM 1,947 menu_one.c
09/16/2001 03:51 PM 1,078 menu_one.ico
09/16/2001 03:51 PM 2,236 menu_one.rc
09/16/2001 03:49 PM 643 resource.h



now lets create a batfile that would compile the c file, .rc and then link them together

Code:

>copy con compile.bat
path = %path%;D:\Borland\BCC55\Bin
brc32 -32 -r menu_one.rc
pause
bcc32 -tW -c menu_one.c
pause

ilink32 -aa c0w32 menu_one.obj,menu_one,,import32 cw32,,menu_one.res
pause
^Z
1 file(s) copied.

>

>dir

02/19/2002 09:38 PM 1,947 menu_one.c
09/16/2001 03:51 PM 1,078 menu_one.ico
09/16/2001 03:51 PM 2,236 menu_one.rc
09/16/2001 03:49 PM 643 resource.h
05/07/2007 12:35 PM 181 compile.bat

>


lets run the batfile

Code:

>compile.bat


>path = C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;D:\Borland\BCC55\Bin

>brc32 -32 -r menu_one.rc
Borland Resource Compiler Version 5.40
Copyright (c) 1990, 1999 Inprise Corporation. All rights reserved.

>pause
Press any key to continue . . .

>bcc32 -tW -c menu_one.c
Borland C++ 5.5.1 for Win32 Copyright (c) 1993, 2000 Borland
menu_one.c:
Warning W8057 menu_one.c 85: Parameter 'hPrevInstance' is never used in function WinMain
Warning W8057 menu_one.c 85: Parameter 'lpCmdLine' is never used in function WinMain

>pause
Press any key to continue . . .

>ilink32 -aa c0w32 menu_one.obj,menu_one,,import32 cw32,,menu_one.res
Turbo Incremental Link 5.00 Copyright (c) 1997, 2000 Borland

>pause
Press any key to continue . . .

>


lets list the directory

Code:

>dir
02/19/2002 09:38 PM 1,947 menu_one.c
09/16/2001 03:51 PM 1,078 menu_one.ico
09/16/2001 03:51 PM 2,236 menu_one.rc
09/16/2001 03:49 PM 643 resource.h
05/07/2007 12:35 PM 181 compile.bat
05/07/2007 12:37 PM 1,340 menu_one.RES
05/07/2007 12:37 PM 4,678 menu_one.obj
05/07/2007 12:37 PM 1,376,256 menu_one.ils
05/07/2007 12:37 PM 1,179,648 menu_one.ilf
05/07/2007 12:37 PM 458,752 menu_one.ilc
05/07/2007 12:37 PM 131,072 menu_one.ild
05/07/2007 12:37 PM 393,216 menu_one.tds
05/07/2007 12:37 PM 49,152 menu_one.exe
05/07/2007 12:37 PM 276 menu_one.map

>



lets run the exe

it runs fine

with linked rc file icons menus an stuff it even squeals woo! in delight when clciked go

check this and save this url to your hardisk

http://www.webnotes.org/bcc55eng.htm

leech all the stuff thats available in the links in that url all are worthwhile having

toolmanx
May 7th, 2007, 07:39
To Blabberer;

Thanks for your great input. Obviously you either
had the tut or took the trouble to go out and get it.

Look at page 99 he calls "The hard way to link in
Borland."

I used it exactly as he noted it. Once I had your way
which I tested and it worked, I looked for differences.
Correct me if I'm wrong but it appears he is missing
the following syntax puctuation:

1. missing a comma between dlg_one.obj and c0w32.
2. He has .obj tied to c0w32.
I'm not sure if this is weird or not.
3. There is no comma between import32.lib and cw32.lib

I realize I don't know all I need to know about commas and
double commas. I'll read up on that.

toolmanx@ij.net

blabberer
May 7th, 2007, 11:26
no i dont have the tutorial i only have the src files folder
so cant see page 99

as to bcc i ve been using it for quiet some time now so i knew the answer offhand

and always the MANUAL is your best friend they dont say RTFM for nothing


so if you had given the manual a spin on ilink

it would have stated

ILINK32 [@respfile][options] startup myobjs, [exe], [mapfile], [libraries], [deffile], [resfile]

comparing this with the commandline i passed

ilink32 -aa c0w32 menu_one.obj,menu_one,,import32 cw32,,menu_one.res

i ignored respfile

for options it is -aa (/aa Builds a 32-bit Windows application )
startup is c0w32 menu_one.obj is myobjs (notice no comma)
menu_one is name of the exe file that would be generated
,, ignored map file name (it will default to menu_one.map)

import32 cw32 == library files
,, ignored deffiles
menu_one.res == precompiled resource file from brc32

thats all is needed

disavowed
May 7th, 2007, 12:07
Quote:
[Originally Posted by LLXX;65479]
Code:
link [options] progname.obj progname.res [libs]
You can find the M$ 32-bit portable executable linker all over the Internet, needless to say you should search for and obtain it.


Especially because you can download it legally for free from microsoft.com

toolmanx
May 7th, 2007, 18:16
Thanks again Blabberer. I printed the Borland help files and have it all in a 3
ring binder. My error was following the tut as written without challenging it
assuming it was perfect. I didn't lay out the items as shown in the book. Right, RTFB.

LLXX
May 8th, 2007, 01:37
Quote:
[Originally Posted by disavowed;65498]Especially because you can download it legally for free from microsoft.com
It comes with the free express edition downloads right?

disavowed
May 8th, 2007, 09:28
Quote:
[Originally Posted by LLXX;65515]It comes with the free express edition downloads right?

Right.