0

我正在使用 catkin 命令行工具构建benchmark_catkin,它是 Google 基准测试的 catkin 包装器。该构建使用 CMakeLists 文件,并且到目前为止在 Ubuntu 18.04 上一直运行良好。我现在正在尝试使用 snapcraft 构建这个包。Snapcraft 有 catkin-tools 插件,并在构建之前设置了一个 VM。但是,我现在从系统库中收到错误并且构建不成功:

In file included from /root/parts/workspace/install/usr/include/x86_64-linux-gnu/bits/fcntl.h:61:0,
                 from /root/parts/workspace/install/usr/include/fcntl.h:35,
                 from /root/parts/workspace/build/benchmark_catkin/benchmark_src-prefix/src/benchmark_src/src/sysinfo.cc:23:
/root/parts/workspace/install/usr/include/x86_64-linux-gnu/bits/fcntl-linux.h:355:27: error: ISO C++ forbids zero-size array ‘f_handle’ [-Wpedantic]
   unsigned char f_handle[0];
                           ^
In file included from /root/parts/workspace/install/usr/include/x86_64-linux-gnu/bits/fcntl.h:61:0,
                 from /root/parts/workspace/install/usr/include/fcntl.h:35,
                 from /root/parts/workspace/build/benchmark_catkin/benchmark_src-prefix/src/benchmark_src/src/timers.cc:23:
/root/parts/workspace/install/usr/include/x86_64-linux-gnu/bits/fcntl-linux.h:355:27: error: ISO C++ forbids zero-size array ‘f_handle’ [-Wpedantic]
   unsigned char f_handle[0];
                           ^
make[5]: *** [src/CMakeFiles/benchmark.dir/sysinfo.cc.o] Error 1
make[5]: *** Waiting for unfinished jobs....
make[5]: *** [src/CMakeFiles/benchmark.dir/timers.cc.o] Error 1
make[4]: *** [src/CMakeFiles/benchmark.dir/all] Error 2
make[4]: *** Waiting for unfinished jobs....
make[3]: *** [all] Error 2
make[2]: *** [benchmark_src-prefix/src/benchmark_src-stamp/benchmark_src-build] Error 2
make[1]: *** [CMakeFiles/benchmark_src.dir/all] Error 2
make: *** [all] Error 2

我假设这个错误是指 libc6-dev 库中的零大小数组。由于我base: core18在我的 snapcraft.yaml 中使用并且还运行 Ubuntu 18.04 系统,我想知道为什么我只是在 VM 中收到错误。这是库中的错误吗?我该如何解决这个问题?


作为参考,我的 snapcraft.yaml 文件:

name: nav 
base: core18 
version: 'w1.0'
summary: The Nav Software  
description: |

grade: devel  
confinement: strict 

plugs:   
  network:
  network-bind:

parts: 

  core-dep:
    plugin: nil
    build-packages:
      - autoconf
      - libtool
      - git

  workspace:
    plugin: catkin-tools
    source: .
    catkin-packages: [catkin_simple, glog_catkin, gflags_catkin, benchmark_catkin]
    after: [core-dep]

根据要求,这里是 /usr/include/x86_64-linux-gnu/bits/fcntl-linux.h 错误行周围的代码:

/* File handle structure.  */
struct file_handle
{
  unsigned int handle_bytes;
  int handle_type;
  /* File identifier.  */
  unsigned char f_handle[0];
};
4

1 回答 1

2

我看了看这个项目。benchmark_catkin 的 CMakeLists.txt 在内部签出 google/benchmark 并构建它。错误来自该版本。

CMakeLists.txt google/benchmark 设置了大量的编译器选项,特别是 -pedantic-errors(以及 -pedantic 和 -Werror),这会导致编译器在任何使用语言扩展时停止。坦率地说,在我看来,CMakeLists.txt 不应该设置任何警告标志,尤其是没有用户要求的 -Werror 或 -pedantic-errors 标志,所以我认为这是一个错误,但谷歌开发人员可能不同意。

glibc 标头使用语言扩展。但这很好,因为系统标题中的警告应该被忽略。所以构建失败的实际原因是未能将 glibc 头文件视为系统头文件。

我对 snapcraft 一无所知,但我怀疑问题的原因就在那里。

于 2020-03-11T17:55:54.513 回答