繁体   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