有一个CMake项目非常简单,但根本没有用Visual代码进行编译。来文提交人:
// 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发布于 2020-10-20 06:13:41
如果授予权限,CMAKE无法访问文件系统。解决方案是相应地编辑/etc/fstab。
https://stackoverflow.com/questions/64438728
复制相似问题