开发者

Unsatisfied symbols in Debug but not Release

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 defi开发者_运维技巧ned 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.


The HPUX Compiler loves to "Optimize away" Constructor calls to global classes if the classes are only accessed indirectly from the main path of execution. Try adding a simple printf() with the value of the variable in your main thread somewhere an see if the problem dissappears.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜