Can not find the resource

S

sealo

Hello, dear guys,
I met another curious issue of finding the resources.

There was a dynamic file, which include a resource:
/////////////////////////////////////////////////////////////////////////////
//
// RCDATA
//

IDR_FX_CLASSICMATERIAL RCDATA "..\\Shaders\
\ClassicMaterial.fx"

And, the app could load the dll, and working fine.

But, I convert it into the the static lib, then it broken down. I
check the code in the library, the error was in FindResource function:
HRSRC hResource = ::FindResource(gModule,
MAKEINTRESOURCE(IDR_FX_CLASSICMATERIAL), RT_RCDATA);
The return value was zero. I don't know why this happen if it's static
library.
The error message was : "The speicified type cannot be found in the
image file"

I first guest maybe it's HINSTANCE fault, but when I add the header
IMAGE_DOS_HEADER, it still the same fault.
Have you met this issue before?
 
E

Ed

Hello, dear guys,
I met another curious issue of finding the resources.

There was a dynamic file, which include a resource:
/////////////////////////////////////////////////////////////////////////////
//
// RCDATA
//

IDR_FX_CLASSICMATERIAL RCDATA "..\\Shaders\
\ClassicMaterial.fx"

And, the app could load the dll, and working fine.

But, I convert it into the the static lib, then it broken down. I
check the code in the library, the error was in FindResource function:
HRSRC hResource = ::FindResource(gModule,
MAKEINTRESOURCE(IDR_FX_CLASSICMATERIAL), RT_RCDATA);
The return value was zero. I don't know why this happen if it's static
library.
The error message was : "The speicified type cannot be found in the
image file"

I first guest maybe it's HINSTANCE fault, but when I add the header
IMAGE_DOS_HEADER, it still the same fault.
Have you met this issue before?

And this module do not use MGC dll, so AfxFindResourceHandle can not
be used here.
 
D

David Lowndes

There was a dynamic file, which include a resource:
/////////////////////////////////////////////////////////////////////////////
//
// RCDATA
//

IDR_FX_CLASSICMATERIAL RCDATA "..\\Shaders\
\ClassicMaterial.fx"

And, the app could load the dll, and working fine.

But, I convert it into the the static lib, then it broken down. I
check the code in the library, the error was in FindResource function:
HRSRC hResource = ::FindResource(gModule,
MAKEINTRESOURCE(IDR_FX_CLASSICMATERIAL), RT_RCDATA);
The return value was zero. I don't know why this happen if it's static
library.
The error message was : "The speicified type cannot be found in the
image file"

The problem is that a static library can't contain any resources.
Unfortunately the tools don't do anything to tell you that, so it's
easy to assume you ought to be able to do it. :(

Dave
 
E

Ed

The problem is that a static library can't contain any resources.
Unfortunately the tools don't do anything to tell you that, so it's
easy to assume you ought to be able to do it. :(

Dave

Is there something workaround to make static library contain the
resources?
And it seems there are many restrict of the conversion from dynamic
lib to static lib in MS.
 
D

David Lowndes

Is there something workaround to make static library contain the
resources?

No, they can't if they're resources. You'd have to arrange to separate
out the resources and include them more directly into the project
you're linking your static library to. Alternatively, include them as
data in the code.

Dave
 
B

Ben Voigt [C++ MVP]

Ed said:
Is there something workaround to make static library contain the
resources?

A compiled resource, aka .res file, does for resources what a .lib does for
code. You'll have to distribute both.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top