检测到编译器ABI失败,原因是CMAKE

时间:2020-10-20 05:00:17

标签: c++ cmake

有一个CMake项目足够简单,但根本无法使用Visual Studio Code进行编译。来源:

// main.cpp
#include <iostream>
int main(int argc, char * argv){
    return 0;
}

CMakeLists.txt:

cmake_minimum_required(VERSION 3.0.0)
project(test VERSION 0.1.0)
add_executable(test main.cpp)

vscode中的CMake工具生成时提示错误如下:

[cmake] -- Detecting C compiler ABI info
[cmake] -- Detecting C compiler ABI info - failed
[cmake] -- Check for working C compiler: /bin/gcc-9
[cmake] -- Check for working C compiler: /bin/gcc-9 - works
[cmake] -- Detecting C compile features
[cmake] -- Detecting C compile features - done
[cmake] CMake Error at /usr/local/share/cmake-3.18/Modules/CMakeTestCCompiler.cmake:82 
(configure_file):
[cmake]   configure_file Problem configuring file
[cmake] Call Stack (most recent call first):
[cmake]   CMakeLists.txt:2 (project)
[cmake] 
[cmake] 
[cmake] -- Detecting CXX compiler ABI info
[cmake] -- Detecting CXX compiler ABI info - failed
[cmake] -- Check for working CXX compiler: /bin/g++-9
[cmake] -- Check for working CXX compiler: /bin/g++-9 - works
[cmake] -- Detecting CXX compile features
[cmake] -- Detecting CXX compile features - done
[cmake] CMake Error at /usr/local/share/cmake-3.18/Modules/CMakeTestCXXCompiler.cmake:75 
(configure_file):
[cmake]   configure_file Problem configuring file
[cmake] Call Stack (most recent call first):
[cmake]   CMakeLists.txt:2 (project)

CMakeError.log:

Cannot copy output executable
'/data/solution/projects/test/build/CMakeFiles/CMakeTmp/cmTC_efc0d'
to destination specified by COPY_FILE:
'/data/solution/projects/test/build/CMakeFiles/3.18.4/CMakeDetermineCompilerABI_C.bin'

Cannot copy output executable
'/data/solution/projects/test/build/CMakeFiles/CMakeTmp/cmTC_26771'
to destination specified by COPY_FILE:
'/data/solution/projects/test/build/CMakeFiles/3.18.4/CMakeDetermineCompilerABI_CXX.bin'

CMakeOutput.log的选择:

The system is: Linux - 5.4.0-52-generic - x86_64
Compiling the C compiler identification source file "CMakeCCompilerId.c" succeeded.
Compiler: /bin/gcc-9 
Build flags: 
Id flags:  

The output was:
0


Compilation of the C compiler identification source "CMakeCCompilerId.c" produced "a.out"

The C compiler identification is GNU, found in 
"/data/solution/projects/test/build/CMakeFiles/3.18.4/CompilerIdC/a.out"

Compiling the CXX compiler identification source file "CMakeCXXCompilerId.cpp" succeeded.
Compiler: /bin/g++-9 
Build flags: 
Id flags:  

The output was:
0


Compilation of the CXX compiler identification source "CMakeCXXCompilerId.cpp" produced "a.out"

The CXX compiler identification is GNU, found in 
"/data/solution/projects/test/build/CMakeFiles/3.18.4/CompilerIdCXX/a.out"

Determining if the C compiler works passed with the following output:
Change Dir: /data/solution/projects/test/build/CMakeFiles/CMakeTmp

Run Build Command(s):/usr/bin/make cmTC_3f39e/fast && /usr/bin/make  -f 
CMakeFiles/cmTC_3f39e.dir/build.make CMakeFiles/cmTC_3f39e.dir/build
make[1]: Entering directory '/data/solution/projects/test/build/CMakeFiles/CMakeTmp'
Building C object CMakeFiles/cmTC_3f39e.dir/testCCompiler.c.o
/bin/gcc-9    -o CMakeFiles/cmTC_3f39e.dir/testCCompiler.c.o -c 
/data/solution/projects/test/build/CMakeFiles/CMakeTmp/testCCompiler.c
Linking C executable cmTC_3f39e
/usr/local/bin/cmake -E cmake_link_script CMakeFiles/cmTC_3f39e.dir/link.txt --verbose=1
/bin/gcc-9 -rdynamic CMakeFiles/cmTC_3f39e.dir/testCCompiler.c.o -o cmTC_3f39e 
make[1]: Leaving directory '/data/solution/projects/test/build/CMakeFiles/CMakeTmp'

当操作系统突然从18.04升级到20.04以及更高版本的GCC工具链(9.3)时,该项目不再构建。

a.out

存在于CMAKE构建目录下,但是正如上面的日志所示,无论如何都没有可复制的输出可执行ABI测试程序。有没有人可以帮助我找到真正的原因?谢谢。

解决方案:好的。多亏了评论,我本来可以指出一个问题。该项目位于安装到FAT32文件系统的目录下,其中权限设置很难配置。正确的/ etc / fstab文件:

UUID=3FCE-E5CB  /data   vfat    rw,user,exec,utf8,uid=jack,gid=jack 0      0

1 个答案:

答案 0 :(得分:0)

在获得许可的情况下,CMAKE无法访问文件系统。解决方案是相应地编辑/ etc / fstab。