[英]To Create a DLL for C++ program in CYGWIN
我正在嘗試將Math.cpp轉換為Cygwin中的dll。 我正在Cygwin中嘗試將此代碼進行編譯。
gcc -c Math.cpp
現在正在嘗試將.o轉換為.dll。 為此,我使用了以下代碼
gcc -shared -o Math.dll Math.o
在cygwin中收到一條巨大的錯誤消息,上面寫着“ Math.o:Math.cpp :(。text + 0x55):對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+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):un0引用`std :: basic_ostream>&std :: operator <<>(std :: basic_ostream>&,char const *)''“等。
在我的C ++程序中,命名空間是std; 類名是Mathematics,有input()和add()兩個方法,還有一個主要方法調用這些方法。
使用g++
而不是gcc
這將導致gcc與標准C ++庫鏈接,該庫應解析這些符號。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.