469,612 Members | 2,200 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,612 developers. It's quick & easy.

Precompiled Headers when building Static Library

I am working on a test migration of our project to Visual Studio 2005 Beta 2
as a precursor to the availability of the full release of VS2005.

The most onerous problem so far concerns the requirement by LINK.EXE that if
an object file has used precompiled headers, then the resulting "precompiled
header object file" must also be one of the objects in the link.

(Whilst it does not affect my problem - I would dearly like to know why this
requirement exists? I thought a precompiled header was simply a pre-parsed
representation of the header...)

My problem is that much of our project is compiled into static libraries
which are then linked by multiple targets within the project.

I find that I cannot link with the static library unless I also link with
the precompiled header object file that was involved in the compile of those
objects in the static library (we have a separate precompiled header per
target in case compile options differ between targets). Interestingly, I
tried putting the precompiled header object file into the library but the
linker will not resolve it from there.

Is this behaviour correct? It seems ludicrous that if I were selling a
static library how on earth would I ship it to customers? With the
precompiled object file separate? Or would I have to forego the benefits of
using precompiled headers?

I could of course be entirely wrong about all of this, so if that's the case
I would appreciate being informed as to what I am doing wrong and how to
correct it.

Kevin.

Nov 17 '05 #1
3 1778
"Kevin Frey" <ke**********@hotmail.com> wrote in message
news:OQ***************@TK2MSFTNGP12.phx.gbl...
I am working on a test migration of our project to Visual Studio 2005 Beta
2 as a precursor to the availability of the full release of VS2005.
It's been available since 10/28 if you're an MSDN subscriber, and since 11/7
for everyone else.
The most onerous problem so far concerns the requirement by LINK.EXE that
if an object file has used precompiled headers, then the resulting
"precompiled header object file" must also be one of the objects in the
link.

(Whilst it does not affect my problem - I would dearly like to know why
this requirement exists? I thought a precompiled header was simply a
pre-parsed representation of the header...)
I believe that it's so the linker can merge the symbol tables from the
PCH-builder into the PDB of the resulting image. Without it, all symbols
defined in the PCH would be missing from the PDB.
My problem is that much of our project is compiled into static libraries
which are then linked by multiple targets within the project.

I find that I cannot link with the static library unless I also link with
the precompiled header object file that was involved in the compile of
those objects in the static library (we have a separate precompiled header
per target in case compile options differ between targets). Interestingly,
I tried putting the precompiled header object file into the library but
the linker will not resolve it from there.

Is this behaviour correct? It seems ludicrous that if I were selling a
static library how on earth would I ship it to customers? With the
precompiled object file separate? Or would I have to forego the benefits
of using precompiled headers?

I could of course be entirely wrong about all of this, so if that's the
case I would appreciate being informed as to what I am doing wrong and how
to correct it.


I've never encountered the problem you describe - but it doesn't sound right
to me either. Hopefully someone else can shed some more light.

-cd
Nov 17 '05 #2
> I've never encountered the problem you describe - but it doesn't sound right
to me either. Hopefully someone else can shed some more light.


Are you saying you've built projects involving multiple static
libraries that were compiled with different precompiled headers and
you've never run into problems? Or are you saying you've simply never
heard of anyone else having this problem?

Nov 17 '05 #3
ke**********@hotmail.com wrote:
I've never encountered the problem you describe - but it doesn't
sound right to me either. Hopefully someone else can shed some more
light.


Are you saying you've built projects involving multiple static
libraries that were compiled with different precompiled headers and
you've never run into problems? Or are you saying you've simply never
heard of anyone else having this problem?


Both.

-cd
Nov 17 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

6 posts views Thread by Asfand Yar Qazi | last post: by
4 posts views Thread by Andrew Ward | last post: by
reply views Thread by Bruno van Dooren | last post: by
20 posts views Thread by Bonj | last post: by
1 post views Thread by Bonj | last post: by
reply views Thread by simon.hudon | last post: by
8 posts views Thread by Abubakar | last post: by
reply views Thread by devrayhaan | last post: by
reply views Thread by gheharukoh7 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.