【问题标题】:Trouble with libgsl and wxwidgetlibgsl 和 wxwidget 的问题
【发布时间】:2012-11-23 13:26:20
【问题描述】:

我在 Windows 7 / Visual Studio 2010 中构建项目时遇到了困难,并且已经花费了比我承认的时间更长的时间来搜索和修复其他错误以达到这一点,但令人沮丧的是,我似乎无法摆脱最后一个错误。存在与 math.h 中定义的 _hypot 函数相关的链接器错误:

wxTheAppInitializer" (?wxTheAppInitializer@@3VwxAppInitializer@@A) 已在 main.obj 1>libgsl.a(linalg_svd.o) 中定义:错误 LNK2019: 函数中引用的未解析的外部符号 _hypot _gsl_linalg_SV_decomp 1>libgsl.a(matrix_oper.o):错误 LNK2001:无法解析的外部符号 _hypot 1>libgsl.a(linalg_householder.o): 错误 LNK2001:未解析的外部符号 _hypot

:致命错误 LNK1120:1 个未解决的外部问题

当我听从unresolved external symbol "_hypot" when using static library 的建议时,我得到以下信息:

1> 生成代码... 1> main.obj : 错误 LNK2005: _hypot 已经 在 About.obj 中定义 1> 致命错误 LNK1169: one or more multiply 找到定义的符号

谁能解释一下是怎么回事?

【问题讨论】:

  • 我意识到如果我完全注释掉 math.h 中的 _hypot,并在我的 main.cc 中重新实现它:#include extern "C" { double hypot(double _X,双 _Y) { 返回 _hypot(_X, _Y); } } 然后我可以构建没有错误。我认为这就是原始帖子的意思。但这似乎是一个非常肮脏的修复。任何人都可以在不永久编辑 math.h 的情况下提出更清洁的修复方法吗?

标签: wxwidgets linker-errors winmain


【解决方案1】:

使用以下内容创建 .c 文件:

extern double fabs(double);
extern double sqrt(double);

double hypot(double x, double y) {
  double ax = fabs(x), ay = fabs(y);
  double xy = x/y, yx = y/x;
  return ax > ay
    ? ax * sqrt(1.0 + yx*yx)
    : ay * sqrt(1.0 + xy*xy);
}

不包括 math.h

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2021-08-02
    • 2022-01-10
    • 2013-10-01
    • 1970-01-01
    • 2013-01-08
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多