Fwd: Linking public: static const members in lib*.a's

Steven T. Hatton hattons@globalsymmetry.com
Fri Sep 10 18:12:00 GMT 2004


On Friday 10 September 2004 06:39, Steven T. Hatton wrote:

It was suggested that I run nm -C on my libraries.  That revealed that 
sth::util::RgbColor::RED was undefined in the ColorTest.o. I added the 
library containing RgbColor.o with -l and its path with -L.  That enabled the 
linker to find what it needed.  

I guess this means that a lib*.a isn't "cumulative" in that it only references 
names in the libraries linked into it. Where can I learn more about what 
things such as this stuff from the nm man page?

           "A" The symbol's value is absolute, and  will  not  be
               changed by further linking.

           "B" The  symbol  is  in the uninitialized data section
               (known as BSS).

           "C" The symbol is common.  Common symbols  are  unini­
               tialized data.  When linking, multiple common sym­
               bols may appear with the same name.  If the symbol
               is   defined  anywhere,  the  common  symbols  are
               treated as undefined references.

This is the nm stuff that gave me the clue I needed.

RgbColor.o:
000001d4 t global constructors keyed to _ZN3sth4util8RgbColorC2ERKhS3_S3_
0000011a t __static_initialization_and_destruction_0(int, int)
00000000 W sth::util::Printable_IF::Printable_IF()
00000000 W sth::util::Printable_IF::~Printable_IF()
00000000 W sth::util::Printable_IF::~Printable_IF()
00000000 W sth::util::Printable_IF::~Printable_IF()
00000000 B sth::util::RgbColor::RED
00000040 T sth::util::RgbColor::RgbColor(unsigned char const&, unsigned char 
const&, unsigned char const&)
00000000 T sth::util::RgbColor::RgbColor(unsigned char const&, unsigned char 
const&, unsigned char const&)
00000000 W sth::util::RgbColor::~RgbColor()
00000000 W sth::util::RgbColor::~RgbColor()
00000080 T sth::util::RgbColor::print(std::basic_ostream<char, 
std::char_traits<char> >&) const
         U std::basic_ostream<char, std::char_traits<char> >::operator<<(int)
00000000 V std::basic_streambuf<char, std::char_traits<char> >::_S_pback_size
00000000 V std::basic_streambuf<wchar_t, std::char_traits<wchar_t> 
>::_S_pback_size
         U std::ios_base::Init::Init()
         U std::ios_base::Init::~Init()
00000008 b std::__ioinit
         U std::basic_ostream<char, std::char_traits<char> >& std::operator<< 
<std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, 
char const*)
00000000 V typeinfo for sth::util::Printable_IF
00000000 V typeinfo for sth::util::RgbColor
00000000 V typeinfo name for sth::util::Printable_IF
00000000 V typeinfo name for sth::util::RgbColor
         U vtable for __cxxabiv1::__class_type_info
         U vtable for __cxxabiv1::__si_class_type_info
00000000 V vtable for sth::util::Printable_IF
00000000 V vtable for sth::util::RgbColor
         U operator delete(void*)
         U __cxa_atexit
         U __cxa_pure_virtual
         U __dso_handle
         U __gxx_personality_v0
000001a4 t __tcf_0
000001bc t __tcf_1


ColorTest.o:
0000012e t global constructors keyed to _ZN3sth9ColorTestC2ERSo
         U _Unwind_Resume
000000d8 t __static_initialization_and_destruction_0(int, int)
00000000 W sth::util::Printable_IF::Printable_IF(sth::util::Printable_IF 
const&)
00000000 W sth::util::Printable_IF::~Printable_IF()
00000000 W sth::util::Printable_IF::~Printable_IF()
00000000 W sth::util::Printable_IF::~Printable_IF()
         U sth::util::RgbColor::RED
00000000 W sth::util::RgbColor::RgbColor(sth::util::RgbColor const&)
00000000 W sth::util::RgbColor::~RgbColor()
00000000 W sth::util::operator<<(std::basic_ostream<char, 
std::char_traits<char> >&, sth::util::Printable_IF const&)
00000066 T sth::ColorTest::ColorTest(std::basic_ostream<char, 
std::char_traits<char> >&)
00000000 T sth::ColorTest::ColorTest(std::basic_ostream<char, 
std::char_traits<char> >&)
000000d2 T sth::ColorTest::~ColorTest()
000000cc T sth::ColorTest::~ColorTest()
00000000 V std::basic_streambuf<char, std::char_traits<char> >::_S_pback_size
00000000 V std::basic_streambuf<wchar_t, std::char_traits<wchar_t> 
>::_S_pback_size
         U std::ios_base::Init::Init()
         U std::ios_base::Init::~Init()
00000000 b std::__ioinit
00000000 V typeinfo for sth::util::Printable_IF
00000000 V typeinfo name for sth::util::Printable_IF
         U vtable for __cxxabiv1::__class_type_info
00000000 V vtable for sth::util::Printable_IF
         U vtable for sth::util::RgbColor
         U operator delete(void*)
         U __cxa_atexit
         U __cxa_pure_virtual
         U __dso_handle
         U __gxx_personality_v0
00000116 t __tcf_0

-- 
Regards,
Steven



More information about the Gcc mailing list