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

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

问题描述

我想开始尝试一些较新的 C++11 功能,似乎最好的支持是 gcc 4.8,而 Squeeze 附带 4.4.5.

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.

但是,我不想对我当前的设置造成任何损害".让 both 版本的 gcc 并排运行的最佳方法是什么?我主要担心大量依赖项,将它们全部纳入我当前的系统可能会使其不稳定.

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?

如果做不到这一点,我可能会创建一个 VM 并在其下运行一个不稳定"的 Debian,但它是一个不太理想的解决方案.

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

推荐答案

如果您从源代码安装 GCC,请确保您没有将其安装到 /usr,它不会搞砸任何事情.如果您以自己的用户身份安装它,而不是 root,那么搞砸系统的可能性为零.

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.

请参阅 http://gcc.gnu.org/wiki/InstallingGCC 了解几乎 -傻瓜式的最低配置.

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

我以我的用户身份构建了各种版本,并为各种 X 安装在 ~/gcc/4.X 中.

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

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

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

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

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天全站免登陆