Dear all,
I would like to know about some concepts of linking process.
I have three files, lets say a.c , b.c and c.c in a project
a.c :
------
int aFunc()
{
return 5 + 6;
}
b.c
-----
void bFunc()
{
aFunc();
}
c.c
----
main()
{
bFunc();
//Code for some other things also.
}
now, the code for aFunc(), bFunc() will be included only if I call bFunc() from c.c, or they are included by default
I mean to ask size of c.exe is always same as sizeof a.obj + sozeof b.obj or it depends on weather I'm calling bFunc
Actually why am I asking this question is I'm facing a severe problem in my project which I could not solve.
For ur reference I'm explaining the scenario :
I have one MFC dialog based application which uses the library engine.lib.
engine.lib internally calls the functions defined in generator.lib
So my project settings includes the libraries : engine.lib, generator.lib
If I call the engineFunc() which is defined in the engine.lib, no errors it is giving.
If I comment that call it is giving me the linker errors.

doubt regarding the linking in the compilation process
Matejko
What may be happening is this:
If you simply include a lib file I think the linker is smart enough not to include it in your exe unless you call something in the lib file.
So, unless you call something in engineFunc from your main executable nothing gets pulled in from the lib files. Once you call the function, engine.lib gets pulled in, and assuming engine.lib calls something in generator.lib, that gets pulled in as well.
Now, you'd think this wouldn't be a problem, and isn't in most situations. However, if you are relying on some sort of initialization to happen that's set up as a global init thingy (either something like "int x = myFunc()" at the global scope, or "MyClass mc()" at the global scope, which implies that this thing has to happen before anything in main since main expects all globals to already be initialized), if the linker doesn't pull in the lib files, this initialization never takes place. This happens to be a problem with some libs, MFC included.
So, perhaps something along those lines is taking place, but it's hard to tell without your actual build logs.
Thanks,
Ben
Ryan Kaelin