nm符号都为"U".和"T"是什么意思? [英] nm symbol both "U" and "T", what does that mean?

查看:1726
本文介绍了nm符号都为"U".和"T"是什么意思?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在运行时遇到未定义的符号错误,当我在相关库中查找符号时,会得到结果:

I am having an undefined symbol error at runtime, and when I look for the symbol in the relevant library, I get the result:

nm -C -D /home/farmer/anaconda3/envs/general/lib/python3.6/site-packages/pyscannerbit/libScannerBitCAPI.so | grep empty_
                 U YAML::detail::node_data::empty_scalar[abi:cxx11]
00000000002b5860 T YAML::detail::node_data::empty_scalar[abi:cxx11]()

那怎么可能呢?该符号既未定义,也位于库中?什么?还是这些实际上是不同的符号?弄乱名称后,它们的名称确实确实有所不同:

But how is that possible? The symbol is both undefined, and also in the library? What? Or are these actually different symbols? When mangled the names are indeed slightly different:

nm -D /home/farmer/anaconda3/envs/general/lib/python3.6/site-packages/pyscannerbit/libScannerBitCAPI.so | grep empty_
                 U _ZN4YAML6detail9node_data12empty_scalarB5cxx11E
00000000002b5860 T _ZN4YAML6detail9node_data12empty_scalarB5cxx11Ev

这有意义吗?

推荐答案

yaml-cpp有两种变体:

There are two variants of yaml-cpp:

https://github.com/jbeder/yaml-cpp

https://github.com/jbeder/yaml-cpp.new-api

在第一个符号中,所涉及的符号声明为成员static const std::string& empty_scalar();. 在第二个中,它被声明为成员static std::string empty_scalar;.

In the first one the symbol in question is declared as member static const std::string& empty_scalar();. In the second one it is declared as member static std::string empty_scalar;.

您看到的两个符号名称与这两个不同的声明匹配.如果编译器看到empty_scalar这样声明不一致,则不应允许这样做.

The two symbol names you see match to these two different declarations. This should not be allowed by the compiler if it sees empty_scalar declared inconsistently like this.

我认为您链接了用不同版本的声明该符号的头文件编译的目标文件.链接器然后会因为这两个符号的名称不同而认为这两个符号不同.您使用的目标文件确实包含old-api变体的定义,但是一些代码正在使用新的.

I think you linked object files which were compiled with different versions of the header file which declared the symbol. The linker would then consider the two symbols different because of their different names. The object file you used did contain the definition for the old-api variant, but some code is using the new one.

这篇关于nm符号都为"U".和"T"是什么意思?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆