在Debian上安装gcc 4.8 [英] Installing gcc 4.8 on Debian

查看:214
本文介绍了在Debian上安装gcc 4.8的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想开始玩一些更新的C ++ 11功能,似乎最好的支持是gcc 4.8,而Squeeze的版本是4.4.5。



但是,我不想对我当前的设置造成任何损坏。获得两个版本的gcc并行运行的最佳方式是什么?我主要关心的是大量的依赖关系,把它们全部放在我目前的系统中可能会使它不稳定。



有没有人设法做到这一点,什么是否涉及步骤?



否则,我可能只是创建一个虚拟机,并运行一个不稳定的Debian,但这是一个不太理想的解决方案。

解决方案

如果您从源代码安装GCC,请确保不将其安装到 / usr 它不会弄乱任何东西。如果你安装它作为你自己的用户,而不是 root ,那么这个系统就没有任何机会。



请参阅 http://gcc.gnu.org/wiki/InstallingGCC 为几乎白痴 -



我有各种版本,作为我的用户构建,并安装在〜/ gcc / 4.X 对于各种X。



唯一需要注意的是使用该设置是新版本的共享库不在动态链接器的默认搜索路径中,所以您需要使用 LD_LIBRARY_PATH 或其他解决方案来确保可执行文件从4.8中找到库,请参阅 libstdc ++ FAQ 及其链接到手册



我使用一个包装器脚本调用 g ++ 11 ,它只需调用新版本的GCC, std = gnu ++ 11 ,并将一个标志传递给链接器,告诉它将路径设置为可执行文件中的4.8个库:

  $ HOME / gcc / 4.8 / bin / g ++ -Wl,-rpath,$ HOME / gcc / 4.8 / lib64 -std = gnu ++ 11 -Wall -Wextra -g$ @


I want to start playing around with some of the newer C++11 features and it appears that the best support for this is with gcc 4.8, and Squeeze ships with 4.4.5.

However, I don't want to cause any "damage" to my current setup. What's the best way to get both versions of gcc running side-by-side? I'm concerned mostly at the large number of dependencies and that taking them all in to my current system may render it unstable.

Has anyone managed to do this, and what are the steps involved?

Failing that, I'll probably just create a VM and run an "unstable" Debian under that but it's a less-than-ideal solution.

解决方案

If you install GCC from source just make sure you don't install it to /usr and it won't mess anything up. If you install it as your own user, not root, then there is zero chance of messing up the system.

See http://gcc.gnu.org/wiki/InstallingGCC for the almost-idiot-proof minimal configuration.

I have various versions built as my user and installed in ~/gcc/4.X for various X.

The only thing to be aware of using that set up is that the shared libraries for the new version aren't in the dynamic linker's default search path, so you need to use LD_LIBRARY_PATH or some other solution to ensure executables find the libs from 4.8, see the libstdc++ FAQ and the page it links to in the manual

I use a wrapper script call g++11 which simply calls the new version of GCC with -std=gnu++11 and passes a flag to the linker telling it to set the path to the 4.8 libs in the executable:

$HOME/gcc/4.8/bin/g++ -Wl,-rpath,$HOME/gcc/4.8/lib64 -std=gnu++11 -Wall -Wextra -g "$@"

这篇关于在Debian上安装gcc 4.8的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆