【问题标题】:downgrading g++ after changing version更改版本后降级g ++
【发布时间】:2014-06-11 08:33:39
【问题描述】:

所以之前我尝试在 C++ 中编译一个 lambda 表达式,我的默认编译器是 gcc-4.4,你知道它不支持 lambda 表达式,所以我尝试安装更新版本的 gcc-4.7,安装成功成功,但之后我无法编译任何程序。

我试图恢复以前版本的 gcc,但 update-alternatives 对我不起作用。

-错误:

    In file included from /usr/local/include/htmlcxx/html/ParserDom.h:5:0,
             from urlServer.cpp:7:
    /usr/local/include/htmlcxx/html/tree.h:118:21: error: ‘ptrdiff_t’ does not name a type
    urlServer.cpp: In lambda function:
    urlServer.cpp:148:29: error: ‘urlHash’ is not captured
    urlServer.cpp:148:38: error: return-statement with a value, in function returning            'void' [-fpermissive]
    In file included from /usr/local/lib/gcc/i686-pc-linux-         gnu/4.7.1/../../../../include/c++/4.7.1/algorithm:63:0,
               from urlServer.cpp:5:
     /usr/local/lib/gcc/i686-pc-linux- gnu/4.7.1/../../../../include/c++/4.7.1/bits/stl_algo.h: In instantiation of  ‘_InputIterator std::__find_if(_InputIterator, _InputIterator, _Predicate,           std::input_iterator_tag) [with _InputIterator =   std::istream_iterator<std::basic_string<char> >; _Predicate =     writeAllLinks(std::list<std::basic_string<char> >)::<lambda(const string&)>]’:
     /usr/local/lib/gcc/i686-pc-linux-    gnu/4.7.1/../../../../include/c++/4.7.1/bits/stl_algo.h:4490:41:   required from ‘_IIter       std::find_if(_IIter, _IIter, _Predicate) [with _IIter =   std::istream_iterator<std::basic_string<char> >; _Predicate =        writeAllLinks(std::list<std::basic_string<char> >)::<lambda(const string&)>]’
     urlServer.cpp:148:39:   required from here
     usr/local/lib/gcc/i686-pc-linux- gnu/4.7.1/../../../../include/c++/4.7.1/bits/stl_algo.h:146:7: error: void value not   ignored as it ought to be

我正在使用 debian

问题:如何恢复以前版本的 gcc?

我知道这个问题已经被问过了,但我找不到答案,我尽我所能,谢谢;

【问题讨论】:

  • 当你说你“不能编译我的任何程序”时,你能详细说明一下吗?你得到什么错误?也许帮助你解决这个问题比回到旧的编译器更容易?
  • 您的标题提出了一个与实际问题不同的问题(新编译器“不起作用”与降级到旧编译器)。
  • 为你们的帮助,我更新了问题并将我遇到的错误放入其中; htmlcxx 是一个从 html 文件中提取 url 的库。
  • 第一个错误(关于ptrdiff_t)是因为4.6中C++库的变化。请参阅this text here(通过简单的搜索很容易找到)以了解更改的内容以及如何修复它的提示。第二个错误是因为您的代码中有某些内容,除非您显示您的代码,否则我们无法帮助您。
  • 它没有作为系统编译器安装(你可能没有使用 Debian 包管理器来安装它)所以它安装在/usr/local 而不是/usr。但是,我敢打赌,它已正确安装在原处,您只需进行一些小改动(查看我之前的评论,然后点击链接)。

标签: c++ c gcc c++11 lambda


【解决方案1】:

1) 只需使用您的 linux 发行版的包管理器再次安装该包。您的工具中还应该有修复包或其他类似选项。不要忘记您需要一个有效的 binutils/gcc/libc/g++/libg++ 组合。也许您的发行版包含一个用于开发的元包,其中包含所有需要的包。

2) 您可以并行安装多个版本的编译器。 只需为您的配置选项提供 --prefix= 即可。我用 /opt/linux-gnu-gcc4.x.x 用于版本。使用 /opt 路径是避免与您的分发包冲突的常见做法。

3) 根本无法编译任何程序的问题不是一个好的问题描述。对我来说,听起来您有一组混合的库标头与不兼容的标头问题。如果没有更详细的错误描述,没有人能理解您所做的事情。但你应该从 1) 开始

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2023-02-07
    • 2023-01-17
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-12-27
    • 2013-02-14
    相关资源
    最近更新 更多