-
-
Notifications
You must be signed in to change notification settings - Fork 290
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to build a static nethogs binary ? #219
Comments
Late to the party, but this can be done like this. Important part is in Containerfile: # https://pkgs.alpinelinux.org/packages
# https://git.alpinelinux.org/aports/tree/main/nethogs/APKBUILD
FROM alpine:latest
ENV pkgver 0.8.7
ENV pkgname nethogs
WORKDIR /root
RUN apk update && apk --no-cache add git wget autoconf automake build-base linux-headers ncurses-dev ncurses-static libpcap-dev
RUN git clone https://github.com/raboof/nethogs "$pkgname-$pkgver"
# RUN wget "https://github.com/raboof/nethogs/archive/v$pkgver/$pkgname-$pkgver.tar.gz" && tar -xzf "$pkgname-$pkgver.tar.gz"
WORKDIR /root/$pkgname-$pkgver
RUN VERSION="$pkgver" CC="gcc -static" LDFLAGS="-static" make nethogs |
@flajr Thank you for your help! Following is my procedure: apt update -y && apt install build-essential libncurses5-dev libpcap-dev autoconf automake && apt upgrade -y cd / git clone https://github.com/raboof/nethogs cd /nethogs CC="gcc -static" LDFLAGS="-static" make Ended up with many undefined error. Would you help me figure out how to make static nethogs in ubuntu? |
Well, sir, Ubuntu is problem. Before you even try to do it, be sure to check possibility of running docker or podman on some machine (friends or yours). In Alpine you can build static binary and than copy it from container to your ubuntu and it just works. If you are absolutely sure to try it on Ubuntu brace yourself. This is not full guide, unfortunatelly: Build ncurses (not with musl or zig but standard gcc on machine should be fine): cd / && wget ftp://ftp.gnu.org/gnu/ncurses/ncurses-6.3.tar.gz && tar -xzf ncurses-6.3.tar.gz && cd ncurses-6.3/
./configure --prefix=/opt/ncurses-6.3 --enable-widec --without-manpages --enable-shared --enable-ext-colors --enable-const && make -j4 && make install Building libpcap you should figure out yourself, lots of knobs in configure script and Ubuntu do not provide static build: git clone https://github.com/the-tcpdump-group/libpcap && cd libpcap
./configure --prefix=/opt/libpcap ... && make -j4 && make install Then I would suggest to use Then if you at least compile ncurses you should be able to try this (This will NOT compile if libpcap is not build and properly linked.): CC="zig cc -static" NCURSES_LIBS="-L/opt/ncurses-6.3/lib" LDFLAGS="-static" make nethogs I do not see possibility to adjust libpcap with something like Happy compilling! |
@flajr Thank you for your great great help !!! Following is my procedure: I installed ubuntu-20.04.5-live-server-amd64.iso and then installed docker on ubuntu #docker pull alpine:latest #docker run -dit -p 2222:22 --name=ok -v /tmp:/tmp alpine #docker ps -a #docker attach e901a5205bc3 (e901a5205bc3 is alpine CONTAINER ID) #cd / #apk update && apk --no-cache add git wget autoconf automake build-base linux-headers ncurses-dev ncurses-static libpcap-dev #git clone https://github.com/raboof/nethogs #cd /nethogs #CC="gcc -static" LDFLAGS="-static" make nethogs #cd src #cp nethogs /tmp/ #exit Finally I can copy the static nethogs executive file form ubuntu host's tmp directory. Really appreciate your comment !!! |
@flajr Would you please take a look at project: I also open an issues "rolandriegel/nload#15" asking help for static compile. Thank you again! |
Hi,
Could you tell me how to build a static nethogs binary ?
Or, is there any parameters to make static nethogs binary ?
Thank you!
The text was updated successfully, but these errors were encountered: