0

I am trying to upgrade the gcc compiler from version 8.3 to 8.4. The official gcc documentation suggests compiling from source method which takes 5 hours on average. I need gcc-8.4 version to build some project components with CMAKE. I tried copying binaries from x (on which I compiled gcc-8.4 from source) located at /usr/local/bin and /usr/local/bin to the same path in y but the cmake produces following error

pi@raspberrypi:~/vingman/loki/bld $ cmake -DUNIT_TESTS=OFF -DPLATFORM=RASPI ../
-- The CXX compiler identification is unknown
-- The C compiler identification is unknown
-- Check for working CXX compiler: /usr/local/bin/c++
-- Check for working CXX compiler: /usr/local/bin/c++ -- broken
CMake Error at /usr/share/cmake-3.13/Modules/CMakeTestCXXCompiler.cmake:45 (message):
  The C++ compiler

"/usr/local/bin/c++"



is not able to compile a simple test program.

  It fails with the following output:

Change Dir: /home/pi/vingman/loki/bld/CMakeFiles/CMakeTmp

Run Build Command:"/usr/bin/make" "cmTC_d4b13/fast"
/usr/bin/make -f CMakeFiles/cmTC_d4b13.dir/build.make CMakeFiles/cmTC_d4b13.dir/build
make[1]: Entering directory '/home/pi/vingman/loki/bld/CMakeFiles/CMakeTmp'
Building CXX object CMakeFiles/cmTC_d4b13.dir/testCXXCompiler.cxx.o
/usr/local/bin/c++     -o CMakeFiles/cmTC_d4b13.dir/testCXXCompiler.cxx.o -c /home/pi/vingman/loki/bld/CMakeFiles/CMakeTmp/testCXXCompiler.cxx
c++: error trying to exec 'cc1plus': execvp: No such file or directory
make[1]: *** [CMakeFiles/cmTC_d4b13.dir/build.make:66: CMakeFiles/cmTC_d4b13.dir/testCXXCompiler.cxx.o] Error 1
make[1]: Leaving directory '/home/pi/vingman/loki/bld/CMakeFiles/CMakeTmp'
make: *** [Makefile:121: cmTC_d4b13/fast] Error 2



CMake will not be able to correctly generate this project.
Call Stack (most recent call first):
  CMakeLists.txt:14 (project)


-- Configuring incomplete, errors occurred!
See also "/home/pi/vingman/loki/bld/CMakeFiles/CMakeOutput.log".
See also "/home/pi/vingman/loki/bld/CMakeFiles/CMakeError.log".

However, the when i check gcc --version on y, it shows version 8.4

pi@raspberrypi:~/vingman/loki/bld $ gcc --version
gcc (GCC) 8.4.0
Copyright (C) 2018 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

Any help or suggestion is appreciated. Thanks in advance. The output of the CMakeError log file is below

Compiling the CXX compiler identification source file "CMakeCXXCompilerId.cpp" failed. Compiler: /usr/local/bin/c++  Build flags:  Id flags:  

The output was: 1 c++: error trying to exec 'cc1plus': execvp: No such file or directory


Compiling the CXX compiler identification source file "CMakeCXXCompilerId.cpp" failed. Compiler: /usr/local/bin/c++  Build flags:  Id flags: -c 

The output was: 1 c++: error trying to exec 'cc1plus': execvp: No such file or directory


Compiling the CXX compiler identification source file "CMakeCXXCompilerId.cpp" failed. Compiler: /usr/local/bin/c++  Build flags:  Id flags: --c++ 

The output was: 1 c++: error: unrecognized command line option ‘--c++’


Compiling the CXX compiler identification source file "CMakeCXXCompilerId.cpp" failed. Compiler: /usr/local/bin/c++  Build flags:  Id flags: --ec++ 

The output was: 1 c++: error: unrecognized command line option ‘--ec++’; did you mean ‘-Weffc++’?


Compiling the CXX compiler identification source file "CMakeCXXCompilerId.cpp" failed. Compiler: /usr/local/bin/c++  Build flags:  Id flags:  

The output was: 1 c++: error trying to exec 'cc1plus': execvp: No such file or directory


Compiling the CXX compiler identification source file "CMakeCXXCompilerId.cpp" failed. Compiler: /usr/local/bin/c++  Build flags:  Id flags: -c 

The output was: 1 c++: error trying to exec 'cc1plus': execvp: No such file or directory


Compiling the CXX compiler identification source file "CMakeCXXCompilerId.cpp" failed. Compiler: /usr/local/bin/c++  Build flags:  Id flags: --c++ 

The output was: 1 c++: error: unrecognized command line option ‘--c++’


Compiling the CXX compiler identification source file "CMakeCXXCompilerId.cpp" failed. Compiler: /usr/local/bin/c++  Build flags:  Id flags: --ec++ 

The output was: 1 c++: error: unrecognized command line option ‘--ec++’; did you mean ‘-Weffc++’?


Checking whether the CXX compiler is IAR using "" did not match "IAR .+ Compiler": c++: fatal error: no input files compilation terminated. Checking whether the CXX compiler is IAR using "" did not match "IAR .+ Compiler": c++: fatal error: no input files compilation terminated. Compiling the C compiler identification source file "CMakeCCompilerId.c" failed. Compiler: /usr/local/bin/gcc  Build flags:  Id flags:  

The output was: 1 gcc: error trying to exec 'cc1': execvp: No such file or directory


Compiling the C compiler identification source file "CMakeCCompilerId.c" failed. Compiler: /usr/local/bin/gcc  Build flags:  Id flags: -c 

The output was: 1 gcc: error trying to exec 'cc1': execvp: No such file or directory


Compiling the C compiler identification source file "CMakeCCompilerId.c" failed. Compiler: /usr/local/bin/gcc  Build flags:  Id flags: -Aa 

The output was: 1 gcc: error trying to exec 'cc1': execvp: No such file or directory


Compiling the C compiler identification source file "CMakeCCompilerId.c" failed. Compiler: /usr/local/bin/gcc  Build flags:  Id flags: -D__CLASSIC_C__ 

The output was: 1 gcc: error trying to exec 'cc1': execvp: No such file or directory


Compiling the C compiler identification source file "CMakeCCompilerId.c" failed. Compiler: /usr/local/bin/gcc  Build flags:  Id flags:  

The output was: 1 gcc: error trying to exec 'cc1': execvp: No such file or directory


Compiling the C compiler identification source file "CMakeCCompilerId.c" failed. Compiler: /usr/local/bin/gcc  Build flags:  Id flags: -c 

The output was: 1 gcc: error trying to exec 'cc1': execvp: No such file or directory


Compiling the C compiler identification source file "CMakeCCompilerId.c" failed. Compiler: /usr/local/bin/gcc  Build flags:  Id flags: -Aa 

The output was: 1 gcc: error trying to exec 'cc1': execvp: No such file or directory


Compiling the C compiler identification source file "CMakeCCompilerId.c" failed. Compiler: /usr/local/bin/gcc  Build flags:  Id flags: -D__CLASSIC_C__ 

The output was: 1 gcc: error trying to exec 'cc1': execvp: No such file or directory


Checking whether the C compiler is IAR using "" did not match "IAR .+ Compiler": gcc: fatal error: no input files compilation terminated. Checking whether the C compiler is IAR using "" did not match "IAR .+ Compiler": gcc: fatal error: no input files compilation terminated. Determining if the CXX compiler works failed with the following output: Change Dir: /home/pi/vingman/loki/bld/CMakeFiles/CMakeTmp

Run Build Command:"/usr/bin/make" "cmTC_4237f/fast" /usr/bin/make -f CMakeFiles/cmTC_4237f.dir/build.make CMakeFiles/cmTC_4237f.dir/build make[1]: Entering directory '/home/pi/vingman/loki/bld/CMakeFiles/CMakeTmp' Building CXX object CMakeFiles/cmTC_4237f.dir/testCXXCompiler.cxx.o /usr/local/bin/c++    
-o CMakeFiles/cmTC_4237f.dir/testCXXCompiler.cxx.o -c /home/pi/vingman/loki/bld/CMakeFiles/CMakeTmp/testCXXCompiler.cxx c++: error trying to exec 'cc1plus': execvp: No such file or directory make[1]: *** [CMakeFiles/cmTC_4237f.dir/build.make:66: CMakeFiles/cmTC_4237f.dir/testCXXCompiler.cxx.o] Error 1 make[1]: Leaving directory '/home/pi/vingman/loki/bld/CMakeFiles/CMakeTmp' make: *** [Makefile:121: cmTC_4237f/fast] Error 2
  • 1
    Compiler is not only a binary `gcc`/`g++` but also the libraries. If you build the compiler (or any other program) for install it on other machine, then you need to install all files, not just selected binaries. In any case, the error `... is not able to compile a simple test program` could mean many things. **Complete** CMake error message could help identify the problem, but you don't provide it. Note, that **images** of *text* are very discourage on Stack Overflow. Instead, paste the **text** itself into the question post. See [ask]. – Tsyvarev Jun 18 '20 at 11:46
  • Also, before trying to use the compiler with CMake, you may try to use the compiler standalone, by compiling simple "Hello world" program. – Tsyvarev Jun 18 '20 at 11:49
  • @Tsyvarev Apologies for the wrong question formatting. I have made some changes and also attached CMakeError outputs. Also, the gcc compiler gives the following error while compiling a hello world c program gcc: error trying to exec 'cc1': execvp: No such file or directory There might be better clarity now. – Syed Muhammad Shahrukh Jun 18 '20 at 12:04
  • 1
    Ok, so it seems that your compiler installation is **incomplete**. As I said above, *partial* installations are rarely working. You need to install all files on your target machine. – Tsyvarev Jun 18 '20 at 12:19
  • For the future: do not use *blockquote* formatting for logs. This formatting doesn't preserve newlines and makes the log harder to read. Use **code formatting** instead. – Tsyvarev Jun 18 '20 at 12:19
  • @Tsyvarev Okay. I just edited the log to code format. Also, i will go back to my original question. Compiling and building from source takes up to 5 hours. Is there a way to upgrade gcc without the long wait? Thanks in advance. – Syed Muhammad Shahrukh Jun 18 '20 at 12:36
  • By default gcc is built for support many programming languages. If you need new gcc only for c++/c code, you may configure gcc to be built only for these languages. See e.g. [this question](https://stackoverflow.com/questions/14728652/how-to-make-a-light-build-of-gcc-with-language-supports-etc-pruned). – Tsyvarev Jun 18 '20 at 13:33

0 Answers0