Question

So previously i tried to compile a lambda expression in c++, my default compiler was gcc-4.4 and as you know it doesn't support lambda expressions, so i tried to install a newer version of gcc-4.7, the installation worked successfully but after that i couldn't compile any of my programs.

i tried to recover the previous version of gcc but update-alternatives doesn't work for me.

-errors:

    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

i'm using debian

question : how can i recover the previous version of gcc?

i know this question is already asked but i couldn't find the answer and i tried all what i could, thanks;

Was it helpful?

Solution

1) Simply install the package again with your package manager of your linux distribution. There should also be something like repair package or other similar options in your tool. Don't forget that you need a valid binutils/gcc/libc/g++/libg++ combination. Maybe your distribution contains a meta package for development, which contains all the needed packages.

2) You can install multiple versions of the compiler in parallel. Simply you have to provide --prefix= to your configure options. I use /opt/linux-gnu-gcc4.x.x for the versions. Using the /opt path is common practice to not collide with packages of your distribution.

3) The problem, that you could not compile any program at all is not a good problem description. For me it sounds that you have a mixed set of library header to incompatible headers problem. Nobody can understand what you do without a much more detailed error description. But you should start with 1)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top