Solved

Embed DLL in .res (windres)

Posted on 2009-04-06
7
1,033 Views
Last Modified: 2012-08-13
I'm keen to share a substantial amount of code between two of my applications. The best way to do this is for me to create a DLL (which I've done) and make both apps use the DLL.

Rather than ship two files to the user (exe and dll) I want to embed the DLL as a resource inside the EXE.

From what I understand, this should be easy. In my header I have:

#define IDR_PKEY_DLL 102

Then, in my .res file I have:

IDR_PKEY_DLL BINARY MOVEABLE PURE res\\Project.dll

However, Windres fails with:

compiling: resource.rc
windres.exe: resource.rc:17: syntax error
0
Comment
Question by:DaveHope
  • 3
  • 3
7 Comments
 
LVL 86

Expert Comment

by:jkr
ID: 24078283
Shouldn't that just be

IDR_PKEY_DLL BINARY "res\\Project.dll"

?

"MOVEABLE" and "PURE" aren't valid resource compiler statements...
0
 
LVL 12

Expert Comment

by:trinitrotoluene
ID: 24080248
take a look at

http://www.cs.fsu.edu/~baker/ada/gnat/html/gnat_ugn_31.html

particularly the section on "Compiling Resources"
0
 
LVL 12

Expert Comment

by:trinitrotoluene
ID: 24080292
does it compile if you use rc??
0
Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

 

Author Comment

by:DaveHope
ID: 24084410
trinitrotoluene:

My resource compiles and works fine with the ICON, VERSIONINFO and DIALOGEX stuff so I'm fairly sure it's not a problem with the way I'm using my resource.

jkr::

I'll give that a go and see how that goes and update you. However, I thought that they were used for the following:

MOVEABLE - Compiled Resources can be moved to compact memory
PURE - No custom resource

They could however be depreciated, so I'll give it a go.

Cheers!

0
 

Author Comment

by:DaveHope
ID: 24084424
Hi,

Just removed MOVEABLE and PURE with the same problem.

I also renamed the "res" folder to "resource" as there was a bug in a previous version of windres version which didn't like using a folder called "res".

RC now reads:

IDR_PKEY_DLL BINARY resource\\Project.dll

Thanks,

Dave
0
 
LVL 12

Expert Comment

by:trinitrotoluene
ID: 24095550
DaveHope: since you are embedding the dll inside the exe why don't you create a static .lib and build your application. This seems more straightforward to me.....

jkr: your comments on this please....
0
 

Accepted Solution

by:
DaveHope earned 0 total points
ID: 24114089
Solved.

Using the correct quotes solved the problem.

Thanks anyway.
0

Featured Post

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

  Included as part of the C++ Standard Template Library (STL) is a collection of generic containers. Each of these containers serves a different purpose and has different pros and cons. It is often difficult to decide which container to use and …
This article shows you how to optimize memory allocations in C++ using placement new. Applicable especially to usecases dealing with creation of large number of objects. A brief on problem: Lets take example problem for simplicity: - I have a G…
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

828 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