问题描述
我不喜欢Alpine Linux中内置的 time
实用程序,而是想根据自己的需要进行改进-我想编辑 time.c
并将其编译为二进制文件。我已经完成了 apk add build-base
来安装gcc,并从Github复制了 time.c
,但是当我执行 gcc /tmp/time.c -o / tmp / time
时,我得到:
I don't like the built-in time
utility in Alpine Linux and would like to improve it for my needs -- I want to edit the time.c
and compile it to a binary. I have done the apk add build-base
to install the gcc and have copypasted the time.c
from Github, but when I do the gcc /tmp/time.c -o /tmp/time
I get the:
/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
?
So I copypasted it too but it relies on dozens more header files. I saw somewhere that I might need the apk add alpine-sdk
and maybe it would also garantee version compatibility so I did it but gcc still does not see header files. Should I provide some -I
flag?
What do I really have to do to finally compile my custom time.c
?
PS:可能有一个时间
的SO标签,但我不能
P.S.: there is probably a SO tag for time
but I can't find it.
UPD:我已经复制了整个 include
文件夹,但是它说:
UPD: I've copied the whole include
folder but it says:
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 */
^~~~~~~~~~~~~~~~~~~~~~
但我什至找不到整个定义的地方
but I can't find where it's defined even in the whole https://github.com/mirror/busybox
UPD:哦,不,它更复杂。
UPD: oh no, it's more complex.
/ # ls -l `which time`
lrwxrwxrwx 1 root root 12 Jan 30 2019 /usr/bin/time -> /bin/busybox
似乎没有 time这样的东西
二进制。
推荐答案
假定GNU时间功能是您的后继选择,而BusyBox 时间
不足以满足您的需求,只需安装软件包(最近在Alpine上可用):
Assuming that GNU time functionality is what your after, and BusyBox time
being insufficient for your needs, just install the GNU time package which was recently made available on Alpine:
apk add time --repository=http://dl-cdn.alpinelinux.org/alpine/edge/testing
安装后,它将替换 / usr / bin / time
带有GNU time可执行文件的BusyBox符号链接。
When installed, it will replace the /usr/bin/time
BusyBox symlink with the GNU time executable.
这篇关于如何在Alpine上编译time.c?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!