I am building something on HPUX. Code works fine in Sun/Linux/AIX.
But on HPUX it complains on
[sshexec] /usr/ccs/bin/ld: Unsatisfied symbols:
[sshexec] globalVar (first referenced in blah.o)
Once again code works in Release but not in Debug. All it does it uses global variable defined in some other file
extern globPck globalVar;
globPck is class that cointains some global stuff.
I am more interested in ideas what could be the reason for this to work in Release but not in Debug.
I looked over .i files (precompiled header file generated with -E) And it seems defined in same way.
I am guessing something that is hit in Release code path fixes it but I am here to hear if yall have some ideas.
The first thing to do when the linker complains that something isn't defined is to go find for yourself where that thing is defined. If you can't find it, then don't expect the linker to find it, either.
What you have shown is a declaration, not a definition. A definition will not have the extern
keyword. There should be a definition in exactly one .cpp file in your project, not a header.
Once you've found the definition, then you can start working on why the linker doesn't see it. Maybe it's only defined when certain symbols are present, such as DEBUG
or NDEBUG
.
If there is no definition, then maybe all uses of it get removed during release compilation (perhaps because all uses occur in assert
statements that the compiler omits), so the missing definition isn't noticed in release mode.