【问题标题】:Undefined reference to __dso_handle_ - compiling C++ on cygwin对 __dso_handle_ 的未定义引用 - 在 cygwin 上编译 C++
【发布时间】:2014-10-27 14:48:31
【问题描述】:

我有一个基本的Hello World C++ 程序,我正在尝试使用g++cygwin 上编译和运行它。代码是:

#include <iostream>
using namespace std;

int main() {

  cout << "Hello world." << endl;
  return 0;
}

使用:g++ helloWorld.cpp -o h 编译它会导致以下错误:
/tmp/ccDO1S4J.o:helloWorld.cpp:(.rdata$.refptr.__dso_handle[.refptr.__dso_handle]+0x0): undefined reference to__dso_handle' collect2: 错误: ld 返回 1 个退出状态`

我一直在阅读其他一些线程,这些线程表明它可能是链接器问题,并且单独调用链接器或使用详细输出可能会导致更多线索。

所以,我做到了:
1. g++ -c helloWorld.cpp -o helloWorld.o(这有效 - 没有错误)。
2. ld -o h helloWorld.o 导致大量未定义引用 __main 或 std::cout 等错误。

我认为这是一个链接问题,我可能需要链接另一个库。非常欢迎任何有关如何解决此问题的指示。

【问题讨论】:

    标签: c++ linker g++


    【解决方案1】:

    通过cygwin 上的安装程序重新安装g++ 有效。

    【讨论】:

      猜你喜欢
      • 2014-09-19
      • 2016-01-14
      • 1970-01-01
      • 1970-01-01
      • 2021-06-08
      • 1970-01-01
      • 1970-01-01
      • 2012-08-30
      • 1970-01-01
      相关资源
      最近更新 更多