在 CYGWIN 中为 C++ 程序创建 DLL
To Create a DLL for C++ program in CYGWIN
我正在尝试将 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 symbol
std::ios_base::Init::Init()Math.o:Math.cpp:(.text$_ZN11Mathematics5inputEv[_ZN11Mathematics5inputEv]+0x21): undefined reference to `std::basic_ostream >& std::operator<< >(std::basic_ostream >&, char const*)''",等等
在我的C++程序命名空间中是std;
class name 是 Mathematics,有两个方法 input() 和 add() 并且有一个调用这些方法的 main 方法。
使用g++
而不是gcc
这将导致 gcc link 使用标准 C++ 库,它应该解析这些符号。
我正在尝试将 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 symbol
std::ios_base::Init::Init()Math.o:Math.cpp:(.text$_ZN11Mathematics5inputEv[_ZN11Mathematics5inputEv]+0x21): undefined reference to `std::basic_ostream >& std::operator<< >(std::basic_ostream >&, char const*)''",等等
在我的C++程序命名空间中是std; class name 是 Mathematics,有两个方法 input() 和 add() 并且有一个调用这些方法的 main 方法。
使用g++
而不是gcc
这将导致 gcc link 使用标准 C++ 库,它应该解析这些符号。