首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >用CMAKE检测编译器ABI失败

用CMAKE检测编译器ABI失败
EN

Stack Overflow用户
提问于 2020-10-20 05:00:17
回答 1查看 15.5K关注 0票数 2

有一个CMake项目非常简单,但根本没有用Visual代码进行编译。来文提交人:

代码语言:javascript
复制
// main.cpp
#include <iostream>
int main(int argc, char * argv){
    return 0;
}

CMakeLists.txt:

代码语言:javascript
复制
cmake_minimum_required(VERSION 3.0.0)
project(test VERSION 0.1.0)
add_executable(test main.cpp)

vscode构建中的CMake工具在提示符中出现错误,如下所示:

代码语言:javascript
复制
[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:

代码语言:javascript
复制
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的选择:

代码语言:javascript
复制
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文件:

代码语言:javascript
复制
UUID=3FCE-E5CB  /data   vfat    rw,user,exec,utf8,uid=jack,gid=jack 0      0
EN

回答 1

Stack Overflow用户

发布于 2020-10-20 06:13:41

如果授予权限,CMAKE无法访问文件系统。解决方案是相应地编辑/etc/fstab。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/64438728

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档