Discussion:
linker strips resource from lib
(too old to reply)
Alessandro Angeli
2010-01-22 00:21:19 UTC
Permalink
I have a solution S with 2 projects:

- P[LIB] builds a static library and includes a resource R

- P[EXE] builds an EXE and explicitly depends on P[LIB]

Everything is compiled and linked correctly: the EXE runs
and can successfully call functions provided by the LIB.
However, it fails to find R embedded in the EXE.

R has been correctly compiled into a RES and dumpbin shows
that R is present in a .rsrc section in the LIB. But the
linker strips R from the LIB when producing the EXE.

The project settings are all left to their defaults.

I am using MSVC 2008 PRO SP1 on XP PRO SP3.

I have an 11 KiB (4 KiB zipped) proof of concept that shows
this behavior.
--
// Alessandro Angeli
// MVP :: DirectShow / MediaFoundation
// mvpnews at riseoftheants dot com
// http://www.riseoftheants.com/mmx/faq.htm
David Lowndes
2010-01-25 07:57:23 UTC
Permalink
Post by Alessandro Angeli
- P[LIB] builds a static library and includes a resource R
- P[EXE] builds an EXE and explicitly depends on P[LIB]
Everything is compiled and linked correctly: the EXE runs
and can successfully call functions provided by the LIB.
However, it fails to find R embedded in the EXE.
R has been correctly compiled into a RES and dumpbin shows
that R is present in a .rsrc section in the LIB. But the
linker strips R from the LIB when producing the EXE.
As far as I know, this is the expected behaviour. If you need a
resource you have to build it into a DLL or EXE.

Dave
Alessandro Angeli
2010-01-25 16:44:06 UTC
Permalink
From: "David Lowndes"
Post by David Lowndes
As far as I know, this is the expected behaviour. If you
need a resource you have to build it into a DLL or EXE.
That wasn't the case before: this is a 3+ year old project
that used to work flawlessly. I haven't worked on it in a
couple of years and only recently have had to make a small
change and discovered this new behavior of the linker.

Also, if that were the case, then why put the resource in
the LIB in the first place? If the linker is never going to
use it, it just wastes space.
--
// Alessandro Angeli
// MVP :: DirectShow / MediaFoundation
// mvpnews at riseoftheants dot com
// http://www.riseoftheants.com/mmx/faq.htm
David Lowndes
2010-01-25 17:05:12 UTC
Permalink
Post by Alessandro Angeli
Post by David Lowndes
As far as I know, this is the expected behaviour. If you
need a resource you have to build it into a DLL or EXE.
That wasn't the case before: this is a 3+ year old project
that used to work flawlessly.
It's always been the case (with MS Win32 tools) - I may be wrong
there, but being able to include resources through static libs has
never worked as far as I know.

What version of tools were you using before? Did you have any special
settings or build procedure that may have achieved the result?

Dave
Alessandro Angeli
2010-01-25 18:25:05 UTC
Permalink
From: "David Lowndes"
Post by David Lowndes
It's always been the case (with MS Win32 tools) - I may
be wrong there, but being able to include resources
through static libs has never worked as far as I know.
What version of tools were you using before? Did you have
any special settings or build procedure that may have
achieved the result?
It was the exact same set of SLN and VCPROJ files. I was
probably using MSVC2005 at the time and afterwards I
upgraded the files to MSVC2008 (the only difference in the
SLN e VCPROJ files themselves is the version number). I
tried with MSVC2005 and now it doesn't work with that one
either, but the project was working fine at the time it was
originally written (it had been tested extensively).
--
// Alessandro Angeli
// MVP :: DirectShow / MediaFoundation
// mvpnews at riseoftheants dot com
// http://www.riseoftheants.com/mmx/faq.htm
Continue reading on narkive:
Search results for 'linker strips resource from lib' (Questions and Answers)
5
replies
what does UNIX mean?
started 2006-09-26 14:21:06 UTC
software
Loading...