Solved

Embed DLL in .res (windres)

Posted on 2009-04-06
7
1,001 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
Comment Utility
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
Comment Utility
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
Comment Utility
does it compile if you use rc??
0
Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

 

Author Comment

by:DaveHope
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
Solved.

Using the correct quotes solved the problem.

Thanks anyway.
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

When writing generic code, using template meta-programming techniques, it is sometimes useful to know if a type is convertible to another type. A good example of when this might be is if you are writing diagnostic instrumentation for code to generat…
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 clear a vector as well as how to detect empty vectors in C++.
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.

744 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

17 Experts available now in Live!

Get 1:1 Help Now