CMake "clang++ is not able compile a simple test program" (Fedora 20)
CMake "clang++ is not able compile a simple test program" (Fedora 20)
所以我尝试安装clang+cmake来编译一个简单的C++程序,但我得到了以下错误:
-- The C compiler identification is GNU 4.8.3
-- The CXX compiler identification is Clang 3.5.0
-- 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
-- Check for working CXX compiler: /usr/local/bin/clang++
-- Check for working CXX compiler: /usr/local/bin/clang++ -- broken
CMake Error at /usr/share/cmake/Modules/CMakeTestCXXCompiler.cmake:54 (message):
The C++ compiler "/usr/local/bin/clang++" is not able to compile a simple
test program.
It fails with the following output:
Change Dir: /home/jtcwang/tmp/CMake/CMake/CMakeFiles/CMakeTmp
Run Build Command:/usr/bin/gmake "cmTryCompileExec697180971/fast"
/usr/bin/gmake -f CMakeFiles/cmTryCompileExec697180971.dir/build.make
CMakeFiles/cmTryCompileExec697180971.dir/build
gmake[1]: Entering directory
`/home/jtcwang/tmp/CMake/CMake/CMakeFiles/CMakeTmp'
/usr/bin/cmake -E cmake_progress_report
/home/jtcwang/tmp/CMake/CMake/CMakeFiles/CMakeTmp/CMakeFiles 1
Building CXX object
CMakeFiles/cmTryCompileExec697180971.dir/testCXXCompiler.cxx.o
/usr/local/bin/clang++ -o
CMakeFiles/cmTryCompileExec697180971.dir/testCXXCompiler.cxx.o -c
/home/jtcwang/tmp/CMake/CMake/CMakeFiles/CMakeTmp/testCXXCompiler.cxx
Linking CXX executable cmTryCompileExec697180971
/usr/bin/cmake -E cmake_link_script
CMakeFiles/cmTryCompileExec697180971.dir/link.txt --verbose=1
/usr/local/bin/clang++
CMakeFiles/cmTryCompileExec697180971.dir/testCXXCompiler.cxx.o -o
cmTryCompileExec697180971 -rdynamic
/usr/bin/ld: cannot find -lstdc++
clang: error: linker command failed with exit code 1 (use -v to see
invocation)
gmake[1]: Leaving directory
`/home/jtcwang/tmp/CMake/CMake/CMakeFiles/CMakeTmp'
gmake[1]: *** [cmTryCompileExec697180971] Error 1
gmake: *** [cmTryCompileExec697180971/fast] Error 2
它甚至没有编译我的程序,因为它无法编译测试程序。
看起来重要的一行在这里:
/usr/bin/ld: cannot find -lstdc++
然而,我已经检查了libstdc++
是否已安装并且是最新的,所以在这一点上我很困惑。
我尝试过的其他东西:
- 使用预构建的二进制文件而不是
sudo yum install clang
- 卸下并重新安装
- 尝试了
clang++ hello.cpp
(hello world程序)。它说没有找到<iostreams>
。clang缺少标准库吗?编辑:更改为<iostream>
会出现与上面相同的链接器错误
一般来说,我不熟悉clang、cmake和C++场景,所以如果有任何提示,我将不胜感激。谢谢
您需要C++库的开发库和头文件,请尝试
yum install libstdc++-devel
您的/home/gnu/bin/c++似乎需要额外的标志来正确链接,而CMake对此一无所知。
要使用/usr/bin/c++作为编译器,请使用-DCMAKE_CXX_compiler=/usr/bin/cC++运行cmake。
此外,CMAKE_PREFIX_PATH变量设置了应该安装项目文件的目标目录。它与CMake安装前缀无关,而且CMake本身已经知道这一点。
相关文章:
- 如何使用 Google Test 向测试添加元数据 / 如何将数据从 Google Test 发送到 TestEven
- Boost.TEST with CLion: "Test framework quit unexpectedly"
- Google Test for OpenCv c++
- 使用 Google Test 对自定义断言函数进行单元测试
- Monty Hall program c++
- 柯南,CMake.test()生成XML报告
- 如何在 google test in windows 中管理断言
- "Program ended with exit code: 0"出现在我的输出的开头?
- google test PrintTo for std::set<std::string>
- 我正在尝试学习如何在 c++ 中传递指针,但出现错误:没有用于调用"test"的匹配函数。我做错了什么?
- Xcode Test Navigator 如何在纯C++项目中显示 Google 测试
- LCM program in C++
- 为什么 C++ 编译器在"c:program filesgnu emacsinclude"中查找包含文件?
- 如何期望通过使用Google Test(Mock)以特定频率调用函数
- 无法将 Google Test NuGet 包添加到 Visual Studio Linux C++ 项目中
- 错误:无效使用非静态成员函数"int test::hotplug_callback(libusb_contex
- 为什么会给出"multiple test case"错误?
- 使用 C++ Boost.Test 组织单元测试?
- 在 EAX 模式下加密数据时"program has stopped working"
- CMake "clang++ is not able compile a simple test program" (Fedora 20)