g++中的多重声明错误(cygwin)
Multiple declaration error in g++ (cygwin)
我最近决定开始编写符合标准的C++,而不是使用Turbo-C++,所以我在Windows 7上下载了cygwin并安装了g++。我尝试运行一个hello world程序:
#include<iostream>
using namespace std;
int main()
{
cout << "Hello World!" << endl;
return 0;
}
并在Cygwin中键入以下内容:
g++ test.cpp -o test
g++ test
希望我没事,我按回车键,发现我的心被这堵巨大的难以理解的文字墙打破了:
$ g++ test.exe
test.exe: In function `mainCRTStartup':
/usr/src/debug/cygwin-1.7.27-2/winsup/cygwin/crt0.c:23: multiple definition of `mainCRTStartup'
/usr/lib/gcc/x86_64-pc-cygwin/4.8.2/../../../../lib/crt0.o:/usr/src/debug/cygwin-1.7.27-2/winsup/cygwin/crt0.c:23: first defined here
test.exe: In function `mainCRTStartup':
/usr/src/debug/cygwin-1.7.27-2/winsup/cygwin/crt0.c:23: multiple definition of `WinMainCRTStartup'
/usr/lib/gcc/x86_64-pc-cygwin/4.8.2/../../../../lib/crt0.o:/usr/src/debug/cygwin-1.7.27-2/winsup/cygwin/crt0.c:23: first defined here
test.exe:cygming-crtbegin.c:(.text+0x60): multiple definition of `__gcc_register_frame'
/usr/lib/gcc/x86_64-pc-cygwin/4.8.2/crtbegin.o:cygming-crtbegin.c:(.text+0x10): first defined here
test.exe:cygming-crtbegin.c:(.text+0xc0): multiple definition of `__gcc_deregister_frame'
/usr/lib/gcc/x86_64-pc-cygwin/4.8.2/crtbegin.o:cygming-crtbegin.c:(.text+0x70): first defined here
test.exe:crt0.c:(.text+0x50): multiple definition of `.weak._Jv_RegisterClasses.__gcc_register_frame'
/usr/lib/gcc/x86_64-pc-cygwin/4.8.2/crtbegin.o:cygming-crtbegin.c:(.text+0x0): first defined here
test.exe:cygming-crtend.c:(.idata+0x178): multiple definition of `__imp__ZSt4cout'
test.exe:cygming-crtend.c:(.idata+0x178): first defined here
/usr/lib/gcc/x86_64-pc-cygwin/4.8.2/crtbegin.o:cygming-crtbegin.c:(.text+0x35): undefined reference to `_Jv_RegisterClasses'
/usr/lib/gcc/x86_64-pc-cygwin/4.8.2/crtbegin.o:cygming-crtbegin.c:(.text+0x35): relocation truncated to fit: R_X86_64_PC32 against undefined symbol `_Jv_RegisterClasses'
/usr/lib/gcc/x86_64-pc-cygwin/4.8.2/../../../../x86_64-pc-cygwin/bin/ld: /usr/lib/gcc/x86_64-pc-cygwin/4.8.2/crtbegin.o: bad reloc address 0x0 in section `.pdata'
collect2: error: ld returned 1 exit status
有人可以看看这个,告诉我我做错了什么吗?
不需要 g++ test
命令
命令g++ test.cpp -o test
将编译并链接您的代码。 您可以使用./test.exe
运行它
相关文章:
- Windows/Cygwin - 不能使用 pybind11 - 犯错误
- 在cygwin中运行c++脚本时发生错误
- 在cygwin中测试新的boost安装时出现cpp错误
- NetBean 和 Cygwin 的 C++ 编译错误?
- 使用Cygwin C++时出现未定义的引用错误,为什么我的文件没有链接?
- FingerJetFXOSE Cygwin 编译错误
- 使用Cygwin win32_api.hpp编译Boost Log中的错误
- cygwin Windows 10错误“ sigfillset在范围”中没有声明
- 在Cygwin上更新为v5.4.0.CMATH会产生错误
- 在Cygwin上构建Nodejs时出现构建错误
- g++中的多重声明错误(cygwin)
- 在Windows 7上使用Cygwin为GCC构建提升 - 引导错误
- x86_64-pc-cygwin-gcc 链接器错误
- Cygwin gcc c++ c99 库错误 stod 无法识别使用的 strtod
- 在cygwin中使用clang的神秘链接器错误"undefined reference to `__gxx_personality_v0'"
- 模板中的C++Cygwin数字常量生成错误
- 在Cygwin中编译C++代码时出现权限错误
- regex.h中的编译错误cygwin没有这样的文件或目录
- cygwin/ Android -ndk中的Android - c++编译错误
- 运行策划程序时出现Cygwin错误