Is "undefined reference" the same as "unresolved external symbol"?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



I am currently converting a computer game project from Microsoft Visual
Studio to GCC. Under Microsoft Visual Studio it builds and runs correctly.
Under GCC it compiles but does not link.

The source file "Battlefield.cpp" contains the line:

extern bool bRemoveOrganFromBeast, bCarryingNarulung, g_bManWillBeAttacked;

The source file "Enemy.cpp" contains the lines:

bool g_bManWillBeAttacked = false, g_bMakingGift = false, g_bGiftAccepted[2]
= { false, false }, g_bEnemyMoveCallback = false;
#pragma message("The symbol \"g_bManWillBeAttacked\" has been defined.")

The compiler output contains the line:

../../Human/Enemy.cpp:23:72: note: #pragma message: The symbol
"g_bManWillBeAttacked" has been defined.

The linker output contains the line:

Battlefield.o:Battlefield.cpp:(.text+0xcd): undefined reference to
`g_bManWillBeAttacked'

and ends with the lines:

/usr/lib/gcc/i686-pc-cygwin/4.8.2/../../../../i686-pc-cygwin/bin/ld:
Battlefield.o: bad reloc address 0xd in section
`.text$_ZN7CListOfI8ISoldierEC1Ev[__ZN7CListOfI8ISoldierEC1Ev]'
/usr/lib/gcc/i686-pc-cygwin/4.8.2/../../../../i686-pc-cygwin/bin/ld: final
link failed: Invalid operation
collect2: error: ld returned 1 exit status

Questions: (1) Does "undefined reference" here mean the same as "unresolved
external symbol" does under Microsoft Visual Studio?
(2) How can that happen when the symbol is obviously defined?



--
View this message in context: http://gcc.1065356.n5.nabble.com/Is-undefined-reference-the-same-as-unresolved-external-symbol-tp1110017.html
Sent from the gcc - Help mailing list archive at Nabble.com.



[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux