Can not find the resource

  • Thread starter Thread starter sealo
  • Start date Start date
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?
 
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.
 
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
 
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.
 
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
 
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.
 
Back
Top