Weird build problem

G

Guest

Hi,

I have a strange build problem.


I am building an exe, this exe links to a number of static libraries
maybe 20 in all and all are built from my code. I am using the gmake
build system and the MS visual studio 2003 compiler and linker.

When I perform a completely clean build the binary builds fine to a
size of 2900K but if i make a small code change to a cxx file and only
perform a build that is not a complete clean build then the binary only
builds to 2200K.


In both cases the code builds without any errors but in the case of the
smaller exe the program starts but just terminates pretty much in thin
air. It Usually terminated in the instance() function of a singleton,
this singleton is a template base class used by a few classes that I
want to be singletons.


I can get it to work for me if I delete only one of the .lib files the
binary links to, it is always the same lib file, then it will build to
2900k without a clean build.


This is very strange, is my build not linking to some file.

Can anyone help me with this one?


Please,
Enda
 
A

Alf P. Steinbach

* (e-mail address removed):
I have a strange build problem.

That's tool specific, and so (unfortunately) off-topic in clc++.

Please ask in a group dedicated to your toolset.

E.g., [microsoft.public.vc.language].
 
P

Phlip

keepyourstupidspam said:
When I perform a completely clean build the binary builds fine to a
size of 2900K but if i make a small code change to a cxx file and only
perform a build that is not a complete clean build then the binary only
builds to 2200K.

Off-topic: VC++ pads your executable with blank segments, to prepare for the
"Edit and Continue" feature. Ask a VC++ newsgroup what's really going on.

On topic: I only use Edit and Continue for weird legacy situations, so I
always turn it off. (Because I try to always use unit tests that go directly
to a suspect point in the code, I don't need to restart and run for a long
time to get to it. So the cost of rebuilding and retesting, for me, is
always lower than the cost of Edit and Continue.)
In both cases the code builds without any errors but in the case of the
smaller exe the program starts but just terminates pretty much in thin
air. It Usually terminated in the instance() function of a singleton,
this singleton is a template base class used by a few classes that I
want to be singletons.

On topic: C++ does not specify the order that static-at-file-scope items
construct. And static-at-class-scope is a special case of
static-at-file-scope. So when you relink - particularily an incremental
link - you might change that order. (Internally, the order depends on stub
code in each .lib file registering your global constructors

The fix might be to construct your Singleton inside a method. Then it
constructs "before first use", which might be after the global items
construct:

Single & getSingle()
{
static Single aSingle;
return aSingle;
}

Also, don't abuse Singletons if you could replace them with a better
structure.

From here, either post platform-neutral code samples about your Singleton to
this group, or post questions about your linker and startup code to a VC++
newsgroup, for the best answers.
 

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

Members online

No members online now.

Forum statistics

Threads
473,780
Messages
2,569,608
Members
45,249
Latest member
KattieCort

Latest Threads

Top