Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unable to build GCC due to c++11 errors

Tags:

c++

g++

build

I need an older version of GCC for installing CUDA toolkit, as CUDA toolkit does not support GCC newer than 5.3.1, and the Fedora machine I am trying to install it on comes with GCC 6. I don't have much control over the machine, so I have had to resort to building GCC myself. The steps I have followed are:

$ cd gcc-5.3.0
$ contrib/download_prerequisites
$ cd ../build
$ ../gcc-5.3.0/configure --prefix=$HOME/local/gcc-5.3.0 --program-suffix=5.3 --enable-shared --enable-multiarch --enable-threads=posix --enable-languages=c,c++,fortran --enable-checking=release --with-tune=generic
$ make

This results in successful configure, but make fails with error:

cfns.gperf:101:1: error: ‘const char* libc_name_p(const char*, unsigned int)’ redeclared inline with ‘gnu_inline’ attribute

There are a whole bunch of other C++11 warnings as well. After some google searches, I figured that this had to do with building GCC 5 or older with GCC 6. I thought it might help if I could force the compiler to follow C++98 instead. So, I tried:

$ export CXXFLAGS="-std=gnu++98"
$ ../gcc-5.3.0/configure ...
$ make

Didn't work. I still keep getting the same C++11 warnings, with build failing with the exact same error. Then, I tried:

$ ../gcc-5.3.0/configure CXXFLAGS="-std=gnu++98" ...
$ make

Again, same error. I peeked at the Makefile this time, and it sure had CXXFLAGS set to -std=gnu++98 here and there. Also, I have tried to build GCC 4.9.3 as well to see if this is a problem tied to a specific release, but I got the same error again.

I am not sure how to proceed further. Any help is much appreciated. Thanks.

like image 425
oczkoisse Avatar asked Dec 18 '16 01:12

oczkoisse


People also ask

Does GCC support C ++ 11?

Master C and Embedded C Programming- Learn as you go C++98 − GCC has full support for the 1998 C++ standard as modified in 2003 and renamed to C++03 and some later defect reports. C++11 − GCC 4.8. 1 was the first complete implementation of the 2011 C++ standard, previously known as C++0x.

Does GCC 11 support C ++ 17?

C++17 features are available since GCC 5. This mode is the default in GCC 11; it can be explicitly selected with the -std=c++17 command-line flag, or -std=gnu++17 to enable GNU extensions as well.

What is GCC compiler error?

This error message indicates that the compiler has encountered a variable name which does not have a corresponding declaration. It can be caused by a missing declaration, or a typing error in the name. Variable names are case-sensitive, so foo and Foo represent different variables.

How do I make GCC warnings as errors?

The specifier for a warning is appended; for example -Werror=switch turns the warnings controlled by -Wswitch into errors. This switch takes a negative form, to be used to negate -Werror for specific warnings; for example -Wno-error=switch makes -Wswitch warnings not be errors, even when -Werror is in effect.


1 Answers

In case someone else had this problem, apparently it's fixed by this patch. If you make the suggested changes (which would be too verbose to mention here, but are simple enough to be done manually) to the GCC source files, then configure and make successfully work without the need to pass -std options. I successfully built GCC 5.3.0 using GCC 6.2.1 with these changes to the source files.

like image 73
oczkoisse Avatar answered Sep 19 '22 14:09

oczkoisse