简体   繁体   English

nm:“U”符号未定义

[英]nm: “U” The symbol is undefined

When I nm on one of my libs: 当我在我的一个lib上nm:

nm libmylib.so nm libmylib.so

I get a line like this 我得到这样一条线

             U _ZNSs4_Rep20_S_empty_rep_storageE@@GLIBCXX_3.4

I checked the man page for nm and I got "U" The symbol is undefined. 我查看了nm的手册页,我得到了“U”符号未定义。 What does an undefined symbol really mean? 未定义的符号究竟意味着什么?

If it is really undefined, then why does nm report it at all? 如果它确实是未定义的,那么为什么nm会报告它呢?

An undefined symbol is a symbol that the library uses but was not defined in any of the object files that went into creating the library. 未定义的符号是库使用的符号,但未在创建库的任何目标文件中定义。

Usually the symbol is defined in another library which also needs to be linked in to your application. 通常,符号在另一个库中定义,该库也需要链接到您的应用程序。 Alternatively the symbol is undefined because you've forgotten to build the code that defines the symbol or you've forgotten to include the object file with that symbol into your library. 或者,符号未定义,因为您忘记构建定义符号的代码,或者您忘记将带有该符号的目标文件包含到库中。

In your case it looks like a symbol from your implementation's C library so you would expect that to be undefined in your own library. 在您的情况下,它看起来像您的实现的C库中的符号,因此您可能希望在您自己的库中未定义。 It will be defined in your libc.so wherever that is, possibly /usr/lib. 它将在你的libc.so中定义,无论在哪里,可能是/ usr / lib。

Deciphering this could be done like this : 解密这个可以这样做:

           U _ZNSs4_Rep20_S_empty_rep_storageE@@GLIBCXX_3.4

Means: 手段:

    U->>> in your library its undefined

what is undefined ? 什么是未定义的?

     _ZNSs4_Rep20_S_empty_rep_storageE

Where it is likely to find it ? 哪里有可能找到它?

      GLIBCXX_3.4

Now for your question : " Why is it undefined : ", Its because The linker is not able to find its definition 现在针对您的问题:“为什么它未定义:”,因为链接器无法找到它的定义

Second Part : "If its undefined why report at all ", , nm utility shall read the whole symbol table of your lib and print it. 第二部分:“如果未定义为什么要报告”,nm实用程序应读取lib的整个符号表并打印出来。 So, its just reading & printing it without applying any operations on it. 因此,它只是阅读和打印它而不对其应用任何操作。

It means that library references that symbol ( std::basic_string<char, std::char_traits<char>, std::allocator<char> >::_Rep::_S_empty_rep_storage in this case?) but that it doesn't define it; 这意味着库引用了这个符号(在这种情况下std::basic_string<char, std::char_traits<char>, std::allocator<char> >::_Rep::_S_empty_rep_storage ?)但它没有定义它; some part of the program you link it with, or some other library is supposed to do that. 你链接它的程序的某些部分,或者其他一些库应该这样做。 If you did mean to define it in your library, it means you didn't link the object file with that symbol's definition with the rest of the library code. 如果您的意思是在库中定义它,则意味着您没有将目标文件与该符号的定义与库代码的其余部分链接起来。

I think it means exactly that: undefined in this object. 我认为这意味着:在这个对象中未定义。 Some symbols are evaluated at run time; 某些符号在运行时进行评估; this is likely to be one of them. 这很可能就是其中之一。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM