How to enable later versions of GCC in eclipse CDT in CentOS 7 - c++

My CentOS 7 machine has a default GCC version of 4.8.5. I want to use a higher version of GCC. So, I executed the following steps in a terminal:
sudo yum install centos-release-scl
sudo yum install devtoolset-10-gcc*
scl enable devtoolset-10 bash
After performing the steps, my GCC is now 10.2.1. I then launched Eclipse CDT (10.2.0) through the terminal. Upon enabling C++20 in Eclipse, I tried to compile a simple "hello world" code, but I received the following error in the Eclipse console:
g++ -std=c++2a -O0 -g3 -Wall -c -fmessage-length=0 -MMD -MP -MF"src/dummy2.d" -MT"src/dummy2.o" -o "src/dummy2.o" "../src/dummy2.cpp"
g++: error: unrecognized command line option ‘-std=c++2a’
make: *** [src/dummy2.o] Error 1
"make all" terminated with exit code 2. Build might be incomplete.
My system PATH variable has the following directory as its first entry: /opt/rh/devtoolset-10/root/usr/bin. So, I don't know why my Eclipse is still using the old GCC 4.8.5. How do I adjust my Eclipse settings so that I am able to compile higher versions of C++ in CentOS 7?

Related

How to resolve: Error when bootstrapping CMake on Linux

I received an error while trying to build CMake on Linux. I could not reach the make step. I read around the web but still couldn't really fix this.
I tried both of these, but neither worked:
$ ./configure --prefix=/opt/cmake
$ ./bootstrap
They resulted in:
CMake Error at CmakeLists.txt:107 (message):
The C++ compiler does not support C++11 (e.g. std::unique_ptr).
-- Configuring incomplete, errors occurred
--------------------------------------------
Error when bootstrapping CMake:
Problem while running initial CMake
--------------------------------------------
And:
command -v g++
/usr/bin/g++
g++ --version
g++ (Ubuntu/Linaro 7.4.0-1ubuntu1~18.04.1) 7.4.0
The code I am trying to compile is in C, so I'm wondering why I'm receiving errors raised with respect to the C++ Compiler? Perhaps any thoughts on this too?
You can set up the specific gcc and g++ version using the following commands.
export CC=path_of_gcc/gcc-version
export CXX=path_of_g++/g++-version
And now run any of the commands:
./configure #OR
./bootstrap

g++: internal compiler error: Segmentation fault (program cc1plus) - where do I start?

I am porting code that compiled on Ubuntu 14.04 to 16.04. I have cloned my git repo, installed dependencies and tried the usual make command, soon I hit a g++: internal compiler error: Segmentation fault (program cc1plus) ... yet I am not sure where to start to diagnose and resolve this issue.
I will share as much as I can, see if someone can guide me through a resolution.
Ubuntu
$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 16.04.2 LTS
Release: 16.04
Codename: xenial
g++
$ g++ --version
g++ (Ubuntu 5.4.0-6ubuntu1~16.04.4) 5.4.0 20160609
python
$ python --version
Python 2.7.12
Some environment variables
PYTHON /usr/bin/python2.7
ARCH x86_64
OS Linux
VERSION 4.4.071generic
PLATFORM linux2
HOSTNAME deploy
USER myUser
WUSS_BUILD NO
CCVER gcc
PYLIBDIR build.x86_64-linux2
LIBDIR build.x86_64-linux2
BINDIR build.x86_64-linux2
ODIR build.x86_64-linux2-gcc
STATICLIBDIR build-static.x86_64-linux2
Error
The make command leads to
+++ Compile mycore/boost_json.cc to build.x86_64-linux2-gcc
g++: internal compiler error: Segmentation fault (program cc1plus) <===
Please submit a full bug report,
with preprocessed source if appropriate.
See <file:///usr/share/doc/gcc-5/README.Bugs> for instructions.
mk/makelib2.inc:48: recipe for target 'build.x86_64-linux2-gcc/mycore/boost_json.o' failed
make[1]: *** [build.x86_64-linux2-gcc/mycore/boost_json.o] Error 4
Makefile:152: recipe for target 'make.stage1c' failed
make: *** [make.stage1c] Error 2
The error message seems to be pointing at a g++ compiler error (?)
makelib2.inc:48
$(ODIR)/%.o : %.c
#mkdir -p $(dir $#)
#echo "+++ Compile $< to $(ODIR)"
#$(CC) -MMD -MP -MF $(#:.o=.d) -c -I$(ODIR) $(CFLAGS) $(CFLAGS_$*) -o $# $<
I realize that this is going to be very difficult to craft a proper question that would lead to getting proper help. So please bear with me and feel free to suggest adding anything that may help. Unfortunately, I can't share the code.
Update
Going to try upgrade g++ to a more recent version. Following this thread
HERE how to install g++ 7 on Ubuntu
HERE how to install gcc 6 on Ubuntu
How I resolved my g++ segmentation fault issue
Inspired by this thread
I executed the following on my Ubuntu 16.04
sudo apt-get install build-essential software-properties-common -y
sudo add-apt-repository ppa:ubuntu-toolchain-r/test -y
sudo apt-get update
sudo apt-get install gcc-snapshot -y
After what g++ was incremented from 5.4.0 to 5.4.1 which resolve the segmentation fault issue
$ g++ --version
g++ (Ubuntu 5.4.1-2ubuntu1~16.04) 5.4.1 20160904
Simply do as you were instructed:
Please submit a full bug report, with preprocessed source if appropriate.
If you can't solve your problem using above methods, you can have a try to check if you are running out of disk space using below command. This is the workaround of my problem.
df -h
sudo du -h --max-depth=1

Update g++ reached from NetBeans under OS X

I am trying to build a C++ project in NetBeans 8.2 under OS X with the C++14 standard. However, I am always getting the error while trying to build:
g++ -c -g -std=c++14 -MMD -MP -MF "build/Debug/GNU-MacOSX/test.o.d" -o build/Debug/GNU-MacOSX/test.o test.cpp
error: invalid value 'c++14' in '-std=c++14'
make[2]: *** [build/Debug/GNU-MacOSX/test.o] Error 1
make[1]: *** [.build-conf] Error 2
make: *** [.build-impl] Error 2
BUILD FAILED (exit value 2, total time: 570ms)
Nevertheless, I can run the same command from the terminal without any problems. My version of g++ is 7.0.0, and so the C++14 standard is fully supported.
Therefore, it seems like NetBeans tries to run some older version of g++, which was probably supplied with the system but now is replaced with a new one. To this I have two questions:
How can it be possible that default versions in the terminal and NetBeans are different?
How can I configure NetBeans to work with the terminal default version?
EDIT:
In the terminal which g++ yields /opt/local/bin/g++. The same is in the field Preferences -> C/C++ -> C++ compiler. Adding the --version argument in NetBeans yields Apple LLVM version 5.1 (clang-503.0.40) (based on LLVM 3.4svn), which is definitely different from the console version. So, I still do not understand: why calling g++ under the same path resolves to different versions in NetBeans and the terminal?

How to build pnacl toolchain

My goal is to make some new function to pnacl toolchain. Before I doing so, I think I should build the pnacl toolchain successfully first.
[11/04 Update]
Finally it works. Some package(bison, byacc, flex) I did't install and caused this problem.
[11/03 Update]
I use ubuntu-14.04.1-desktop-amd64 as my system
Also, ubuntu-12.04.5-desktop-amd64 is now testing [11/03 updated]
I've followed the step of the document all the way. Everything goes just fine until I run the toolchain_build_pnacl script
So I add the new error message here :
if I run the script using gcc to compile
toolchain_build/toolchain_build_pnacl.py --gcc --verbose --sync --clobber
--install toolchain/linux_x86/pnacl_newlib
then the following error message is
gcc -DHAVE_CONFIG_H -I. -I../../../src/binutils/gold
-I../../../src/binutils/gold -I../../../src/binutils/gold/../include - I../../../src/binutils/gold/../elfcpp -DLOCALEDIR="\"/share/locale\""
-DBINDIR="\"/bin\"" -DTOOLBINDIR="\"/arm-pc-nacl/bin\"" -DTOOLLIBDIR="\"/arm-pc-nacl/lib\"" -W -Wall -Wstrict-prototypes -Wmissing-prototypes -Wshadow -Werror -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -frandom-seed=yyscript.o -Wno-extended-offsetof -Wno-absolute-value -Wno-unused-function -Wno-unused-const-variable -Wno-unneeded-internal-declaration -Wno-unused-private-field -Wno-format-security -MT yyscript.o -MD -MP -MF .deps/yyscript.Tpo -c -o yyscript.o yyscript.c yyscript.c:1:1: error: return type defaults to ‘int’ [-Werror=return-type] yyscript.c:1:1: error: function
declaration isn’t a prototype [-Werror=strict-prototypes] cc1: error:
unrecognized command line option "-Wno-unused-private-field" [-Werror]
cc1: error: unrecognized command line option
"-Wno-unneeded-internal-declaration" [-Werror] cc1: error:
unrecognized command line option "-Wno-unused-const-variable"
[-Werror] cc1: error: unrecognized command line option
"-Wno-absolute-value" [-Werror] cc1: error: unrecognized command line
option "-Wno-extended-offsetof" [-Werror] cc1: all warnings being
treated as errors make[4]: *** [yyscript.o] Error 1
if I run it with default clang to compile
toolchain_build/toolchain_build_pnacl.py --verbose --clobber
--install toolchain/linux_x86/pnacl_newlib
then following error message is generated
/home/albaforia/SVN/nativeclient/third_party/llvm-build/Release+Asserts/bin/clang
-DHAVE_CONFIG_H -I. -I../../../src/binutils/gold -I../../../src/binutils/gold -I../../../src/binutils/gold/../include -I../../../src/binutils/gold/../elfcpp -DLOCALEDIR="\"/share/locale\"" -DBINDIR="\"/bin\"" -DTOOLBINDIR="\"/arm-pc-nacl/bin\"" -DTOOLLIBDIR="\"/arm-pc-nacl/lib\"" -W -Wall -Wstrict-prototypes -Wmissing-prototypes -Wshadow -Werror -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -frandom-seed=yyscript.o -Wno-extended-offsetof -Wno-absolute-value -Wno-unused-function -Wno-unused-const-variable -Wno-unneeded-internal-declaration -Wno-unused-private-field -Wno-format-security -MT yyscript.o -MD -MP -MF .deps/yyscript.Tpo -c -o yyscript.o yyscript.c yyscript.c:1:1: error: type specifier missing, defaults to 'int' [-Werror,-Wimplicit-int]
main() { return 0;
} ^~~~ 1 error generated. make[4]: *** [yyscript.o] Error 1
By default the PNaCl toolchain builds with a downloaded binary of clang because Google's automated builders run Ubuntu 12.04, and the gcc on those systems cannot build recent versions of LLVM. So there are 2 options:
If you used Chromium's depot_tools to get the Native Client sources, you can easily get a copy of the same compiler the builders use: from the parent directory of native_client run
tools/clang/scripts/update.sh which will download and install clang in the directory where toolchain_build_pnacl.py expects it. Once it is installed, it will be kept up to date automatically by Native Clients DEPS hooks if you use gclient from depot_tools.
Otherwise you can use the system gcc to compile the PNaCl toolchain using the --gcc option. This should definitely work on Ubuntu 14.04 as that the system we develop PNaCl on.
As an aside I've started another document that has a few more details on the build process (even if its focus isn't exactly what you are interested in) and of course there is the -h flag of toolchain_build_pnacl.py and its sources.
Could you post more information on what the error is? You probably need to scroll up a bit (the errors are interleaved with other parts of the build because it builds in parallel). To help debug this you could also run toolchain_build/toolchain_build_pnacl.py on specific targets and reduce the amount of building that goes on, e.g. you could do:
toolchain_build/toolchain_build_pnacl.py llvm_x86_64_linux --verbose --install toolchain/linux_x86/pnacl_newlib
FYI, when you re-run the toolchain_build/toolchain_build_pnacl.py script you don't need to re-specify --sync and --clobber.
You can also run the make command manually as you debug the issue. In any case we'd like to fix the issue you're running into!
To use system compiler instead of compiler from third_party/llvm_build/... you may want to pass the --gcc option to the build script. Though, it's still unlikely that you'll succeed in building toolchain under Ubuntu 14.04.
I'm using Ubuntu 14.04 and in order to build pnacl toolchain I have set up Ubuntu 12.04 chroot environment. Inside it I can successfully build the toolchain using the following commands:
# get sources for NaCl itself
gclient config http://src.chromium.org/native_client/trunk/src/native_client#13992 --name native_client
gclient sync -j16
cd native_client
# sync sources for binutils, llvm, etc.
toolchain_build/toolchain_build_pnacl.py --verbose --sync-only
# build and install toolchain
toolchain_build/toolchain_build_pnacl.py --verbose --gcc --install install_dir
PS: I mount /proc, /dev, /dev/pts, /sys, /run, /run/shm, /tmp into my chroot environment and everything runs smoothly. Without mounting some of these directories some build scripts may fail, though I'm not sure about it.

python installation "cc1.exe: error: unrecognized command line option '-mno-cygwin'"

Hi guys i'm trying to install rrdtool (for PYTHON 2.7) on my windows 7 system , i install it using this command line.
python setup.py install build --compiler=mingw32
it gives me the following output:
running install
running build
running build_ext
running build_configure
building 'rrdtoolmodule' extension
C:\MinGW\bin\gcc.exe -mno-cygwin -mdll -O -Wall -Irrdtool-1.4.7/src -IC:\Python2
7\include -IC:\Python27\PC -c rrdtool-1.4.7/bindings/python/rrdtoolmodule.c -o b
uild\temp.win32-2.7\Release\rrdtool-1.4.7\bindings\python\rrdtoolmodule.o
cc1.exe: error: unrecognized command line option '-mno-cygwin'
error: command 'gcc' failed with exit status 1
i have tried many solutions to solve this, but had no success.i'm using mingw version 4.6.2
can anyone pls help me .
See this answer: https://stackoverflow.com/a/6035864/1516291
you need to edit distutils\cygwinccompiler.py in your Python directory to remove all instances of -mno-cygwin
good luck