GCC 4.4.3编译器链接问题
GCC 4.4.3 compiler linking issue
好的,所以我试图回到c++,并从一个基本的程序开始。
#include <iostream>
using namespace std;
int main()
{
cout << "So This Is It.";
cout << "n";
return 0;
}
结果如下:
-->gcc -g -o HELLO HELLO.cpp
/tmp/ccLZLm5N.o: In function `main':
/root/Programming/Learning/C++/HELLO.cpp:9: undefined reference to `std::cout'
/root/Programming/Learning/C++/HELLO.cpp:9: undefined reference to `std::basic_ostream<char, std::char_traits<char> >& std::operator<< <std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*)'
/root/Programming/Learning/C++/HELLO.cpp:10: undefined reference to `std::cout'
/root/Programming/Learning/C++/HELLO.cpp:10: undefined reference to `std::basic_ostream<char, std::char_traits<char> >& std::operator<< <std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*)'
/tmp/ccLZLm5N.o: In function `__static_initialization_and_destruction_0':
/usr/include/c++/4.4/iostream:72: undefined reference to `std::ios_base::Init::Init()'
/usr/include/c++/4.4/iostream:72: undefined reference to `std::ios_base::Init::~Init()'
/tmp/ccLZLm5N.o:(.eh_frame+0x12): undefined reference to `__gxx_personality_v0'
collect2: ld returned 1 exit status
我的编译器:
-->gcc --version
gcc (Ubuntu 4.4.3-4ubuntu5.1) 4.4.3
Copyright (C) 2009 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
所以我能得到一些关于修复的信息吗?或。如果我遇到任何更简单的语法问题,我如何找到正确的信息?
您使用的是C
编译器而不是C++
编译器。gcc
代表C, g++
代表c++。GCC的链接器将链接到C标准库,该标准库不包含c++标准库提供的函数,这将导致未定义的引用。
所以使用正确的g++
:
g++ -g -o HELLO HELLO.cpp
附加备注:
通常gcc
标识一个c++源代码。然而,如果你没有自己安装g++
,很可能你的Ubuntu安装中没有安装它。要么让你的主管安装g++
,要么自己安装g++
:
sudu apt-get install g++
因为你已经在安装东西了,所以获取gdb
和valgrind
用于调试。
相关文章:
- 静态数据成员的问题-修复链接错误会导致编译器错误
- 基于boost的程序的静态链接——zlib问题
- 使用jsoncpp库时出现链接问题
- Cmake 链接问题:未定义对 Button::mousePressEvent(QGraphicsSceneMouseE
- sqlite3 和生成文件中的链接出现问题
- 如何将GTest与CMake一起使用?遵循谷歌指南时的链接问题
- 未解决的外部链接问题
- 使用转换器提升 Python 问题 - 静态链接
- 'make check' GLIBC 运行时的链接问题
- 在树莓派上用libtorch构建程序时的链接问题
- QtCreator with C 库中的链接器问题
- 野牛弹性链接问题
- 与 AWS 开发工具包的链接问题
- 使用 NVIDIA GPU 在 Cygwin 中链接 OpenCL 库时遇到问题
- 为什么当我从语句检查中删除"+ mod"时,以下程序给出错误的答案。问题链接:https://www.codechef.com/problems/FFC219B
- PCL 和 CMake 的问题:链接时未定义统计异常值删除
- VC++使用gumbo查询时出现问题(链接错误)
- 使用CMake问题链接Boost(Ubuntu 14.04)
- MySQL连接器问题-链接等等
- MinGW 与 MSVC 的 dll 库问题链接(未定义的引用)