Solved

Resources in Static Libraries?

Posted on 2001-07-31
5
1,227 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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
>>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
Comment Utility
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

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

This tutorial is about how to put some of your C++ program's functionality into a standard DLL, and how to make working with the EXE and the DLL simple and seamless.   We'll be using Microsoft Visual Studio 2008 and we will cut out the noise; that i…
For most people, the WrapPanel seems like a magic when they switch from WinForms to WPF. Most of us will think that the code that is used to write a control like that would be difficult. However, most of the work is done by the WPF engine, and the W…
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…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

771 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now