未解析的外部符号"_hypot"使用静态库时 [英] unresolved external symbol "_hypot" when using static library

查看:174
本文介绍了未解析的外部符号"_hypot"使用静态库时的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试重新编译链接Ruby库的旧游戏,但我不断收到此错误:

I'm trying to recompile my old game which links the Ruby library, but I keep getting this error:

ruby​​18-mt-static-release.lib(math.obj):错误LNK2001:未解决 外部符号_hypot

ruby18-mt-static-release.lib(math.obj): error LNK2001: unresolved external symbol _hypot

是否有不需要我找到该库的源代码并重新构建的变通办法?

Is there any workaround for this that doesn't require me finding the source code to this library and rebuilding it?

我正在使用Visual Studio 2010和最新的DirectX SDK.

I'm using Visual Studio 2010 and the latest DirectX SDK.

推荐答案

我遇到了类似的问题.显然hypot曾经是一个可链接的函数,但是现在(我有VS 2010)是一个内联函数,它调用_hypot.在math.h中,这是唯一完成此功能的函数.我没有正在使用的现有库的源代码,并且已将其与hypo链接在一起,因此无法使用内联版本.如果我自己定义hypot,则链接器会说它已经定义.以下工作可解决此问题:

I had a similar problem. Apparently hypot used to be a linkable function but is now (I have VS 2010) an inline function that calls _hypot. In math.h this is the only function where this is done. I don't have source for the existing library I am using and it has hypot linked to it so it can't use the inline version. If I just define hypot myself the linker says it is already defined. The following works to fix this:

  • 编辑math.h并注释或ifdef删除hypot的内联版本.
  • 将hypot用作外部"C" double hypot(double x,double y){返回_hypot(x,y);}
  • 重新链接

丑陋,但是解决了这个问题.

Ugly, but it solved the problem.

这篇关于未解析的外部符号"_hypot"使用静态库时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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