Solved

Resources in Static Libraries?

Posted on 2001-07-31
5
1,236 Views
Last Modified: 2013-12-03
I am using Microsoft Visual C++ 6.0.

How can I include Resources into Static Libraries?
In my case, I want to include String Resources.
What di I have to consider?

Thanks,
Markus
0
Comment
Question by:mskohut
  • 2
  • 2
5 Comments
 
LVL 15

Expert Comment

by:NickRepin
ID: 6338461
There is CVTRES.EXE utility in the "...\Microsoft Visual Studio\VC98\Bin\" directory.

You can use it to convert .RES file to .OBJ file. Then you can include the .OBJ file into the static library .LIB

To compile .RC file into .RES use the standard Microsoft RC.EXE utility, or DevStudio environment.
0
 
LVL 5

Expert Comment

by:robpitt
ID: 6340122
Nick, have you ever made this work?



CVTRES on a RES produces an OBJ file with the following sections:
 46 .debug$S
 A0 .rsrc$01
300 .rsrc$02

These can be put into a LIB no problem *BUT* when you actually link you get an EXE with no resource directory and no rsrc sections:
E.g.
 6000 .data
 1000 .idata
 2000 .rdata
 1000 .reloc
21000 .text


Any thoughts?


Rob
0
 
LVL 5

Expert Comment

by:robpitt
ID: 6340180
Futher investigation has convinced me that the linker simply won't accept mulitple resource files or resource data from inside LIB files.

This is why I have allways resorted to encoding the data as plain "C". Then I load it using the CreateXXXXIndirect functions().

Rob
0
 
LVL 15

Accepted Solution

by:
NickRepin earned 100 total points
ID: 6342624
>>Nick, have you ever made this work?

No, that's why it is only a comment

>>when you actually link you get an EXE with no resource
directory and no rsrc sections

The stupid MS linker has no option to force the linking of a certain obj from a library. Unfortunately, an obj from res does not contain any external symbols, and /INCLUDE option cannot be used.

>>the linker simply won't accept mulitple resource files

It's true, the twice stupid MS linker cannot use several .res files.


Well, you can use only one obj file with resources inside. You have to use this obj separately, of before the linking you have to extract this obj from the lib.
0
 

Author Comment

by:mskohut
ID: 6360025
I think the only way is to supply source .rc code in the static library that I can #include in the resource file of my project which uses the static library.

Has anybody a better solution?

Markus
0

Featured Post

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article surveys and compares options for encoding and decoding base64 data.  It includes source code in C++ as well as examples of how to use standard Windows API functions for these tasks. We'll look at the algorithms — how encoding and decodi…
As more and more people are shifting to the latest .Net frameworks, the windows presentation framework is gaining importance by the day. Many people are now turning to WPF controls to provide a rich user experience. I have been using WPF controls fo…
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …

825 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question