"Kevin" <
XXXX@XXXXX.COM >wrote in message
Quote
A static lib in my project group has the pragma link statement, not the
main project. There are no errors generated when the lib is built, so I
assume that TeeJPEG has been successfully linked during the lib build.
No linking is generally done when building a static library. All unresolved
externals are resolved when linking the final executable. You would not want
any external object files to be included in your own static lib anyway -- it
would lead to a lot of problems if many different static libs all contained
the same code from some common lib (especially if they all included code
from different versions of said common lib), and also it would mean you'd
have to rebuild your static lib every time the lib you were using was
updated if you wanted to take advantage of new changes.
Static libs are just a collection of object files, all external references
are left unresolved. All references are collected and resolved when the
executable is built, so you must link your executable to any static libs
that other static libs are dependant on.
Quote
Since this is a static lib, is my assumption not correct that all obj
files would be included (including TeeJPEG) in the lib?
Yes, your assumption is not correct. Putting the #pragma link in the header
causes the linker to link to that lib when that header is included in your
project. No linking is done when building static libs, and the #pragma link
has no effect on the build of your static lib whatsoever.
All -your- object files are included in your library. External object files
are not -- the linker does not extract the object files from external libs
and then reinclude them in your own. The reason your library is a "static"
library is because -your- code is compiled into your library, and so all the
functions in your library are included in the final executable that links to
your static lib. This is opposed to a dynamic library, where your code is in
a DLL or some other file, rather than in your final executable, and that
other file must be present at run time. But, whether your lib is "static" or
"dynamic" has no bearing on whether or not other libs you use are also
static or dynamic, and again, all linking is done when the final executable
is built.
As for the file not being found, I don't know. But this is why you are only
seeing linker errors when building the executable.
Quote
My confusion is that I only get the linker error when I build the main
project, and there are no references to TeeJPEG in any of the main project
files.
Kevin
"Bob Gonder" < XXXX@XXXXX.COM >wrote in message
news: XXXX@XXXXX.COM ...
>Kevin wrote:
>
>>Is the project linker looking for the TeeJPG.obj file in the static lib,
>>and
>>it is missing? Or is the project linker looking for it in the system
>>path?
>
><HELP>
>#pragma link "[path]modulename[.ext]"
>
>By default, the linker searches for modulename in the local directory and
>any path
>specified by the -L option. You can use the path argument to specify a
>directory.
>
>By default, the linker assumes a .obj extension.
></HELP>
>
>So if TeeJPEG is actually a library, you would need to say so:
>#pragma link "TeeJPEG.lib"
>
>