简体   繁体   English

x86_64-pc-cygwin-gcc链接器错误

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

I setup in my cygwin environment the x86_64-pc-cygwin-gcc package to get a recent gcc 我在cygwin环境中设置了x86_64-pc-cygwin-gcc软件包,以获取最新的gcc

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

I have a small code file that you can find here to build i use the following line: 我有一个小的代码文件,您可以在这里找到要建立的代码,我使用以下代码行:

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

Compilation is OK, but I get several link error about std::istream see below. 编译是可以的,但是我收到一些关于std :: istream的链接错误,请参见下文。 What is the issue does it means I missed a package during the setup ? 这是什么问题,这意味着我在设置过程中错过了一个包裹?

/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

Since you're compiling C++ code with gcc rather than g++ you will need to at least add -lstdc++ to your command line. 由于您是使用gcc而不是g++编译C ++代码,因此至少需要在命令行中添加-lstdc++ Better to just use g++ in the first place though. 最好首先使用g++

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 链接器错误“重定位R_X86_64_PC32对未定义的符号”尽管使用-fPIC进行编译 - linker error “relocation R_X86_64_PC32 against undefined symbol” despite compilation with -fPIC Linker 错误:“针对符号‘xmlFree’重新定位 R_X86_64_PC32 ... 使用 -fPIC 重新编译”但有问题的库已经使用 -fPIC 编译 - Linker error: “relocation R_X86_64_PC32 against symbol `xmlFree' … recompile with -fPIC” but offending library was already compiled with -fPIC 体系结构x86_64参考链接器错误的未定义符号 - Undefined symbols for architecture x86_64 reference linker error 架构 x86_64 的未定义符号:linker 错误 - Undefined symbols for architecture x86_64: linker error 链接器错误:“架构 x86_64 的未定义符号” - Linker error: "Undefined symbols for architecture x86_64" 将c ++项目的类型从x86更改为x64后的链接器错误 - linker error after changed the type of c++ project from x86 to x64 从 x86 更改为 x64 后的链接器错误 - linker error after changing from x86 to x64 Apple Mach O-Linker错误Xcode(C ++):体系结构x86_64的未定义符号 - Apple Mach O-Linker Error Xcode (C++): Undefined symbols for architecture x86_64 “ ld:找不到体系结构x86_64的符号”上的“铛:错误:链接器命令失败,退出代码为1” - “clang: error: linker command failed with exit code 1” on “ld: symbol(s) not found for architecture x86_64” 链接器错误:ld:找不到体系结构x86_64的符号 - Linker error : ld: symbol(s) not found for architecture x86_64
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM