簡體   English   中英

x86_64-pc-cygwin-gcc鏈接器錯誤

[英]x86_64-pc-cygwin-gcc linker error

我在cygwin環境中設置了x86_64-pc-cygwin-gcc軟件包,以獲取最新的gcc

$ x86_64-pc-cygwin-gcc --version
x86_64-pc-cygwin-gcc (GCC) 4.8.1

我有一個小的代碼文件,您可以在這里找到要建立的代碼,我使用以下代碼行:

 x86_64-pc-cygwin-gcc -std=c++11 -std=gnu++11 TreasureHunter.cpp

編譯是可以的,但是我收到一些關於std :: istream的鏈接錯誤,請參見下文。 這是什么問題,這意味着我在設置過程中錯過了一個包裹?

/cygdrive/c/Users/abuisson/AppData/Local/Temp/cc9qeGVh.o:TreasureHunter.cpp:(.text+0x60): undefined reference to `std::istream::operator>>(int&)'
/cygdrive/c/Users/abuisson/AppData/Local/Temp/cc9qeGVh.o:TreasureHunter.cpp:(.text+0x60): relocation truncated to fit: R_X86_64_PC32 against undefined symbol `std::istream::operator>>(int&)'
/cygdrive/c/Users/abuisson/AppData/Local/Temp/cc9qeGVh.o:TreasureHunter.cpp:(.text+0x7c): undefined reference to `std::istream::operator>>(int&)'
/cygdrive/c/Users/abuisson/AppData/Local/Temp/cc9qeGVh.o:TreasureHunter.cpp:(.text+0x7c): relocation truncated to fit: R_X86_64_PC32 against undefined symbol `std::istream::operator>>(int&)'
/cygdrive/c/Users/abuisson/AppData/Local/Temp/cc9qeGVh.o:TreasureHunter.cpp:(.text+0xc2): undefined reference to `std::basic_istream<char, std::char_traits<char> >& std::operator>><char, std::char_traits<char> >(std::basic_istream<char, std::char_traits<char> >&, char&)'
/cygdrive/c/Users/abuisson/AppData/Local/Temp/cc9qeGVh.o:TreasureHunter.cpp:(.text+0xc2): relocation truncated to fit: R_X86_64_PC32 against undefined symbol `std::basic_istream<char, std::char_traits<char> >& std::operator>><char, std::char_traits<char> >(std::basic_istream<char, std::char_traits<char> >&, char&)'
/cygdrive/c/Users/abuisson/AppData/Local/Temp/cc9qeGVh.o:TreasureHunter.cpp:(.text+0x11e): undefined reference to `std::istream::operator>>(int&)'
/cygdrive/c/Users/abuisson/AppData/Local/Temp/cc9qeGVh.o:TreasureHunter.cpp:(.text+0x11e): relocation
truncated to fit: R_X86_64_PC32 against undefined symbol `std::istream::operator>>(int&)'
/cygdrive/c/Users/abuisson/AppData/Local/Temp/cc9qeGVh.o:TreasureHunter.cpp:(.text+0x2d2): undefined reference to `std::ios_base::Init::Init()'
/cygdrive/c/Users/abuisson/AppData/Local/Temp/cc9qeGVh.o:TreasureHunter.cpp:(.text+0x2d2): relocation
truncated to fit: R_X86_64_PC32 against undefined symbol `std::ios_base::Init::Init()'
/cygdrive/c/Users/abuisson/AppData/Local/Temp/cc9qeGVh.o:TreasureHunter.cpp:(.text+0x2ed): undefined reference to `std::ios_base::Init::~Init()'
/cygdrive/c/Users/abuisson/AppData/Local/Temp/cc9qeGVh.o:TreasureHunter.cpp:(.text+0x2ed): relocation
truncated to fit: R_X86_64_PC32 against undefined symbol `std::ios_base::Init::~Init()'
/usr/lib/gcc/x86_64-pc-cygwin/4.8.1/../../../../x86_64-pc-cygwin/bin/ld: /cygdrive/c/Users/abuisson/AppData/Local/Temp/cc9qeGVh.o: bad reloc address 0x0 in section `.pdata$_ZSt4__lgl'
/usr/lib/gcc/x86_64-pc-cygwin/4.8.1/../../../../x86_64-pc-cygwin/bin/ld: final link failed: Invalid operation
collect2: error: ld returned 1 exit status

由於您是使用gcc而不是g++編譯C ++代碼,因此至少需要在命令行中添加-lstdc++ 最好首先使用g++

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM