【问题标题】:To Create a DLL for C++ program in CYGWIN在 CYGWIN 中为 C++ 程序创建 DLL
【发布时间】:2015-05-21 09:04:42
【问题描述】:

我正在尝试将 Math.cpp 转换为 Cygwin 中的 dll。 我正在尝试在 Cygwin 中编译这段代码。

gcc -c Math.cpp

现在我正在尝试将 .o in 转换为 .dll。为此,我使用了以下代码

gcc -shared -o Math.dll Math.o 

在 cygwin 中哪里收到一条巨大的错误消息,上面写着“Math.o:Math.cpp:(.text+0x55): undefined reference to std::ios_base::Init::Init()' Math.o:Math.cpp:(.text+0x55): relocation truncated to fit: R_X86_64_PC32 against undefined symbolstd::ios_base::Init::Init()Math. o:Math.cpp:(.text$_ZN11Mathematics5inputEv[_ZN11Mathematics5inputEv]+0x21): 未定义引用`std::basic_ostream >& std::operator(std::basic_ostream >&, char const*)''"等等。

在我的 C++ 程序命名空间是 std; 类名是数学,有两个方法 input() 和 add() 并且有一个 main 方法调用这些方法。

【问题讨论】:

    标签: c++ cygwin


    【解决方案1】:

    使用g++ 而不是gcc

    这将导致 gcc 链接到标准 C++ 库,该库应该解析这些符号。

    【讨论】:

      猜你喜欢
      • 2011-10-06
      • 2020-03-03
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-03-12
      • 2018-07-26
      • 1970-01-01
      相关资源
      最近更新 更多