使用 GNU 链接器链接到 VC++ 时出现名称修改问题编译库

发布于 2024-09-15 12:35:47 字数 782 浏览 8 评论 0原文

在提出这个问题时,我是在寻求更好地了解情况,或者最好是找到解决方案。

我创建了 C++ 代码,我希望能够使用 Eclipse CDT IDE 而不是 Visual Studios(我的工作场所对 Eclipse 更友好)。这意味着,实际上,我必须使用 GNU 工具链来编译我的代码。对于手头的项目,我必须链接到一个名为 HyDE.lib 的库,该库是使用 Visual Studios 编译器编译的。当然,我遇到的问题是 GNU 链接器无法在 HyDE 中找到适当的符号,因为(我推测)两个编译器都使用不同的名称修改方案。

那么我该如何解决这个问题呢?

目前的想法:

  • 最明显的事情是使用 GNU 工具链重新编译 HyDE.lib。事实证明,这比它的价值更复杂。然而,有一种途径我还没有研究过。我们有一个 cmake 文件,据说可以构建到 unix...有没有办法让 cmake 代替使用 Cygwin GNU?我真的对 cmake 一无所知(对 make 也知之甚少),所以引用好的信息会很好。
  • 我可以将 Eclipse CDT 连接到 Window 编译器工具。是的,但我只能说这并不容易,而且我可能会失去调试,甚至可能失去代码完成。然后是 Eclipse Wascana,但我最近读到一篇博客,表明 Wascana 社区正在衰弱。
  • 是否有任何类型的库分解器-重组器?我想象一个程序,我也会给一个 Windows 编译的库,该程序会挑选出符号,对它们进行分解,然后创建一个具有相同符号的库,但以 GNU 方式进行分解。此时我正在编造一些东西,所以也许有人可以帮助我更好地理解这里的名称修改。

有什么想法吗?

In asking this question, I'm looking for either better understanding of the situation or preferably a solution.

I'm created C++ code and I would like to be able to use the Eclipse CDT IDE rather than Visual Studios, (my workplace is more Eclipse friendly). This implies that, practically speaking, I must use the GNU tool chain to compile my code. For the project at hand, I must link to a library called HyDE.lib that was compiled with the Visual Studios compiler. Of course, the problem that I run into is that the GNU linker can't find the appropriate symbols in HyDE because (I presume) both compilers use different name mangling schemes.

So how do I get around this?

Current thoughts:

  • The most obvious thing would be to recompile HyDE.lib with the GNU tool chain. This is proving to be more complicated than perhaps it's worth. However there is one avenue that I haven't investigated here. We have a cmake file that supposedly can build to unix... is there some way to have cmake instead use Cygwin GNU? I really know nothing about cmake (and very little about make), so a reference to good information would be nice.
  • I could connect Eclipse CDT to the Window compiler tools. Yes, but best I can tell this is not easy, and I would potentially lose debugging and maybe even code completion. Then there is Eclipse Wascana, but I read a recent blog that indicated that the Wascana community is waining.
  • Is there any sort of library demangler-remangler? I imagine a program that I would give a Windows compiled library too, and the program would pick out the symbols, demangle them, and then create a library that had the same symbols, but mangled in the GNU way. At this point I'm making stuff up, so maybe someone could help me better understand name mangling here.

Any ideas?

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

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

发布评论

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

评论(2

鯉魚旗 2024-09-22 12:35:47

除非您将大部分代码放入带有 extern "C" 块的 HyDE.lib 中,否则最好的选择是使用 G++ 重新编译它。即使您确实将其放在 extern "C" 块中,我仍然建议使用 G++ 编译它,因为它通常(但并非总是)比 MSVC 对标准有更好的支持。

Unless you place most of the code in HyDE.lib with extern "C" blocks, then your best bet is to recompile it with G++. Even if you do place it in extern "C" blocks, I would still reccomend compiling it with G++ as it usually (but not always) has better support for standards than MSVC.

痴者 2024-09-22 12:35:47

作为替代方案,将库编译为 .dll 文件并使用它。只需确保将入口点放在 extern "C" 块中即可。

As an alternative, complete the compilation of the library into a .dll file and use that. Just make sure to put entry points in extern "C" blocks.

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