Solved

Embed DLL in .res (windres)

Posted on 2009-04-06
7
1,012 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

In days of old, returning something by value from a function in C++ was necessarily avoided because it would, invariably, involve one or even two copies of the object being created and potentially costly calls to a copy-constructor and destructor. A…
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 viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.

914 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

19 Experts available now in Live!

Get 1:1 Help Now