linux 下安装 c++编译器的方法
2015-07-20 18:34
471 查看
假设你的电脑能够访问internet,这个命令会自动从网络下载并把软件安装到本地。
超级用户权限:
#yum -y install gcc-c++
另外一定不要天真的认为linux 下面 编译C++程序,可以用直接用gcc filename.cc,否则会莫名的出现好多链接错误错误。如下:
oot@fedora-odl-1 test]# gcc temp.cc
/tmp/ccGyH0kl.o: In function `main':
temp.cc:(.text+0x87): undefined reference to `std::cout'
temp.cc:(.text+0x8c): undefined reference to `std::ostream::operator<<(int)'
temp.cc:(.text+0x91): undefined reference to `std::basic_ostream<char, std::char_traits<char> >& std::endl<char, std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&)'
temp.cc:(.text+0x99): undefined reference to `std::ostream::operator<<(std::ostream& (*)(std::ostream&))'
/tmp/ccGyH0kl.o: In function `__static_initialization_and_destruction_0(int, int)':
temp.cc:(.text+0xc7): undefined reference to `std::ios_base::Init::Init()'
temp.cc:(.text+0xd6): undefined reference to `std::ios_base::Init::~Init()'
collect2: error: ld returned 1 exit status
[root@fedora-odl-1 test]#
用g++编译则没有问题了 呵呵
或者用gcc指定链接库
gcc temp.cc -lstdc++因为gcc默认不会去链接C++库。
假设你的电脑能够访问internet,这个命令会自动从网络下载并把软件安装到本地。
超级用户权限:
#yum -y install gcc-c++
另外一定不要天真的认为linux 下面 编译C++程序,可以用直接用gcc filename.cc,否则会莫名的出现好多链接错误错误。如下:
oot@fedora-odl-1 test]# gcc temp.cc
/tmp/ccGyH0kl.o: In function `main':
temp.cc:(.text+0x87): undefined reference to `std::cout'
temp.cc:(.text+0x8c): undefined reference to `std::ostream::operator<<(int)'
temp.cc:(.text+0x91): undefined reference to `std::basic_ostream<char, std::char_traits<char> >& std::endl<char, std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&)'
temp.cc:(.text+0x99): undefined reference to `std::ostream::operator<<(std::ostream& (*)(std::ostream&))'
/tmp/ccGyH0kl.o: In function `__static_initialization_and_destruction_0(int, int)':
temp.cc:(.text+0xc7): undefined reference to `std::ios_base::Init::Init()'
temp.cc:(.text+0xd6): undefined reference to `std::ios_base::Init::~Init()'
collect2: error: ld returned 1 exit status
[root@fedora-odl-1 test]#
用g++编译则没有问题了 呵呵
或者用gcc指定链接库
gcc temp.cc -lstdc++因为gcc默认不会去链接C++库。
相关文章推荐
- PHP计划任务:如何使用Linux的Crontab执行PHP脚本(转)
- 【Linux】ubutun14.04配置JDK1.8
- linux使用crontab实现PHP执行定时任务(转)
- Linux 基础命令
- linux 安装jsoncpp
- boost在linux下的编译和使用
- 【Linux操作系统】Linux内核插入卸载模块
- 怎么在linux下俘获程序奔溃时的调用堆栈
- Linux_centos6.5安装QtCreator
- 初识 linux expect
- c语言基于Linux下用libpcap实现抓包程序
- LINUx 信号摘要
- 源码编译openssl(Linux/Win)
- 01 Linux档案与目录管理
- 查看linux启动的线程信息
- Linux进程间通信——使用信号
- Linux下调整根目录的空间大小
- 史上最全的Linux常用命令
- linux文件基本操作(2)
- centos在root用户下不能使用ibus和mount的中文乱码