c - 如何在 Alpine 上编译 time.c?

标签 c build alpine-linux

我不喜欢 Alpine Linux 中内置的 time 实用程序,并希望根据我的需要改进它 - 我想编辑 time.c并将其编译为二进制文件。我已经完成了 apk add build-base 来安装 gcc,并从 Github 复制粘贴了 time.c,但是当我执行 gcc/tmp/time 时.c -o/tmp/time 我得到:

/tmp/time.c:34:10: fatal error: libbb.h: No such file or directory
 #include "libbb.h"
          ^~~~~~~~~

所以我也复制粘贴了它,但它依赖于数十个头文件。我在某处看到我可能需要 apk add alpine-sdk ,也许它也能保证版本兼容性,所以我这样做了,但 gcc 仍然看不到头文件。我应该提供一些 -I 标志吗?
我到底需要做什么才能最终编译我的自定义 time.c

P.S.:time 可能有一个 SO 标签,但我找不到它。

UPD:我已经复制了整个 include 文件夹,但它显示:

In file included from /tmp/time.c:34:
include/libbb.h:406:42: error: 'ENABLE_FEATURE_VERBOSE' undeclared here (not in a function)
  FILEUTILS_VERBOSE         = (1 << 12) * ENABLE_FEATURE_VERBOSE, /* -v */
                                          ^~~~~~~~~~~~~~~~~~~~~~

但即使在整个 https://github.com/mirror/busybox 中我也找不到它的定义位置

UPD:哦不,它更复杂。

/ # ls -l `which time`
lrwxrwxrwx    1 root     root            12 Jan 30  2019 /usr/bin/time -> /bin/busybox

似乎不存在诸如时间二进制之类的东西。

最佳答案

假设您需要 GNU 时间功能,而 BusyBox time 不足以满足您的需求,只需安装 GNU time最近在 Alpine 上提供的软件包:

apk add time --repository=http://dl-cdn.alpinelinux.org/alpine/edge/testing

安装后,它将用 GNU time 可执行文件替换 /usr/bin/time BusyBox 符号链接(symbolic link)。

关于c - 如何在 Alpine 上编译 time.c?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57589231/

相关文章:

c++ - 未知的 nvlink 错误

exception - 任务 : ':app:preDexDebug' 执行失败

docker - 在带有参数的 docker 容器中运行 "apk add"命令

linux - 在 Alpine 上编译 Mongo

go - 你如何让 -tags netgo 成为 go 的默认值?

c++ - GDB加载so文件失败并报错No such file or directory

c - 如何在 node.js 中创建较低级别的网络数据包

c - PC Lint while(TRUE) 与 for(;;)

c - 打印序列中出现次数最多的数字

ios - Codenameone-iOS调试构建失败