How do I compile the time.c on Alpine?

可紊 提交于 2019-12-13 03:26:53

问题


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"
          ^~~~~~~~~

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?

P.S.: there is probably a SO tag for time but I can't find it.

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: oh no, it's more complex.

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

Seems like there is no such thing as time binary.


回答1:


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

When installed, it will replace the /usr/bin/time BusyBox symlink with the GNU time executable.



来源:https://stackoverflow.com/questions/57589231/how-do-i-compile-the-time-c-on-alpine

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!