gpt4 book ai didi

c++ - gcc-4.8无法编译测试程序?

转载 作者:太空宇宙 更新时间:2023-11-04 05:56:34 26 4
gpt4 key购买 nike

我在 Ubuntu 16.04 上安装了 gcc-4.8 来构建 C++11 程序。我有一个CMakeList.txt该文件在 OS X 上运行良好,并使用从 Macports 构建的 Clang 和 GCC 4.8。

我首先设置 CXX=/usr/bin/gcc-4.8然后 CMake 失败并出现以下错误:

-- The C compiler identification is GNU 5.4.0
-- The CXX compiler identification is unknown
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /usr/bin/gcc-4.8
-- Check for working CXX compiler: /usr/bin/gcc-4.8 -- broken
CMake Error at /usr/share/cmake-3.5/Modules/CMakeTestCXXCompiler.cmake:54 (message):
The C++ compiler "/usr/bin/gcc-4.8" is not able to compile a simple test
program.

It fails with the following output:

Change Dir: /home/ruipacheco/databaseclient/cpp/ninja/CMakeFiles/CMakeTmp

Run Build Command:"/usr/bin/make" "cmTC_5df0c/fast"

/usr/bin/make -f CMakeFiles/cmTC_5df0c.dir/build.make
CMakeFiles/cmTC_5df0c.dir/build

make[1]: Entering directory
'/home/ruipacheco/databaseclient/cpp/ninja/CMakeFiles/CMakeTmp'

Building CXX object CMakeFiles/cmTC_5df0c.dir/testCXXCompiler.cxx.o

/usr/bin/gcc-4.8 -o CMakeFiles/cmTC_5df0c.dir/testCXXCompiler.cxx.o -c
/home/ruipacheco/databaseclient/cpp/ninja/CMakeFiles/CMakeTmp/testCXXCompiler.cxx

gcc-4.8: error trying to exec 'cc1plus': execvp: No such file or directory

CMakeFiles/cmTC_5df0c.dir/build.make:65: recipe for target
'CMakeFiles/cmTC_5df0c.dir/testCXXCompiler.cxx.o' failed

make[1]: *** [CMakeFiles/cmTC_5df0c.dir/testCXXCompiler.cxx.o] Error 1

make[1]: Leaving directory
'/home/ruipacheco/databaseclient/cpp/ninja/CMakeFiles/CMakeTmp'

Makefile:126: recipe for target 'cmTC_5df0c/fast' failed

make: *** [cmTC_5df0c/fast] Error 2

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

-- Configuring incomplete, errors occurred!

再说一遍,我知道gcc-4.8能够构建 C++11 程序,我已经成功做到了 CMakeLists.txt文件在 OSX 上与 gcc 4.8 一起工作,那么我可能会缺少什么?

最佳答案

“gcc-4.8”是C编译器,而不是C++编译器。您应该将 CXX 变量设置为“g++-4.8”或“g++”或其他一些 C++ 编译器可执行文件。

关于c++ - gcc-4.8无法编译测试程序?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46858807/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com