名称修改和转储箱

发布于 2024-12-19 13:32:47 字数 887 浏览 3 评论 0原文

昨天我正在帮助朋友编译Intel的MKL Java示例。尽管一切看起来都很好(根据示例文件/makefile),我们还是遇到了“未解决的外部问题”的问题。

然后我使用了 Visual Studio 的 dumpbin检查库中是否存在未解析的函数。未解析的外部的一个示例是名为 _cblas_sgemm 的函数。当从库(dumpbin /symbols mkl_core.lib)转储符号时,我只能在库上找到一个函数cblas_sgemm,它错过了前缀_。然后我发现该函数实际上仅称为 cblas_sgemm,并且编译器添加了 _ 前缀,作为名称修改规则的一部分。

TL;DR

那么,我的问题是:

  1. dumpbin 是否显示库中入口点的全名?或者由于某种原因它实际上“解开了”这个名字?
  2. 该库是随安装包一起提供的,所以不知道是用哪个编译器编译的。不同的编译器会产生不同的名称吗?

我真的不认为我做对了;我可能在其他地方做错了什么,但我想确定这两个问题。

此处有一个没有答案的类似问题。

Yesterday I was helping a friend to compile Intel's MKL Java examples. We were having issues with "unresolved externals", even though everything seemed fine (accordingly to the example files / makefile).

I then used Visual Studio's dumpbin to check whether the unresolved functions were present in the library. One example of a unresolved external was a function called _cblas_sgemm. When dumping the symbols from the library (dumpbin /symbols mkl_core.lib), I was only able to find a function cblas_sgemm on the library, which missed the prefix _. I then discovered that the function actually was only called cblas_sgemm, and that the compiler added the _ prefix, as part of the name mangling rule.

TL;DR

So, my questions are:

  1. Does dumpbin displays the full name of the entry point in the library? Or for some reason it actually "unmangles" the name?
  2. The library came with the installation package, so I don't know which compiler was used to compile it. Does different compilers produce different names?

I don't really think I got it right; I'm probably doing something wrong somewhere else, but I want to be sure about those two questions.

A similar question with no answers is here.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

晌融 2024-12-26 13:32:47
  1. dumpbin 将显示库中(而不是源代码中)符号的全名,没有任何更改。对于 MS 损坏的 C++ 名称,它将在括号中显示原始符号(如果它可以找出原始符号)。 (使用 dumpbin 9.00.21022.08 进行测试)

  2. 不同的编译器确实会生成不同的符号,特别是对于 C++ 符号。对于符号,编译器往往会就名称修改达成一致,因此 extern "C" 符号可以在不同编译器之间链接。

这是一篇关于名称修改的维基百科文章。

  1. dumpbin will show the full name of symbol in the library(not in the source), without any alternation. For MS mangled of C++ names, it will show the original symbol in parenthesis (if it can figure out the original symbol). (tested with dumpbin 9.00.21022.08)

  2. Different compilers do generate different symbols, especially for C++ symbols. For symbols, compilers tend to have an agreement about name mangling, so extern "C" symbols can be linked between different compilers.

Here is an wikipedia article about name mangling.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文