Open gsbabil opened 6 years ago
Hi @gsbabil
I have compiled sngrep statically in my gentoo box without problem using the following:
$ ./bootstrap.sh
$ CFLAGS=-static ./configure --enable-unicode
[...]
configure: sngrep configure finished
configure: ======================================================
configure: GnuTLS Support : no
configure: OpenSSL Support : no
configure: Unicode Support : yes
configure: Perl Expressions Support : no
configure: IPv6 Support : no
configure: EEP Support : no
configure: ======================================================
$ V=1 make
gcc -static -o sngrep sngrep-capture.o sngrep-address.o sngrep-packet.o
sngrep-sip.o sngrep-sip_call.o sngrep-sip_msg.o sngrep-sip_attr.o
sngrep-main.o sngrep-option.o sngrep-group.o sngrep-filter.o sngrep-keybinding.o
sngrep-media.o sngrep-setting.o sngrep-rtp.o sngrep-util.o sngrep-hash.o
sngrep-vector.o curses/sngrep-ui_panel.o curses/sngrep-scrollbar.o
curses/sngrep-ui_manager.o curses/sngrep-ui_call_list.o curses/sngrep-ui_call_flow.o
curses/sngrep-ui_call_raw.o curses/sngrep-ui_stats.o curses/sngrep-ui_filter.o
curses/sngrep-ui_save.o curses/sngrep-ui_msg_diff.o curses/sngrep-ui_column_select.o
curses/sngrep-ui_settings.o -lmenuw -lformw -lpanelw -lncursesw -lpcap -lpthread
$ ldd src/sngrep
not a dynamic executable
$ src/sngrep -I tests/aaa.pcap -N
Dialog count: 6
So the problem must be elsewhere in your build environment. Your gcc doesn't even have the -static
parameter. Also take into account that you need the static version (.a) of every required library to create a static binary, in my box for example:
$ ls -1 /usr/lib64/libpcap*.a /usr/lib64/lib*w.a
/usr/lib64/libformw.a
/usr/lib64/libmenuw.a
/usr/lib64/libncurses++w.a
/usr/lib64/libncursesw.a
/usr/lib64/libnssckfw.a
/usr/lib64/libpanelw.a
/usr/lib64/libpcap.a
Even without the -static
flag, your dynamic linking build is failing. The error suggests the ncurses version (5.1 from year 2000?) you are using does not have doupdate
function. Not sure what is the minimum required version of ncurses to compile sngrep to be honest. The oldest version I have compiled the code is ncurses 5.7 from debian squeeze.
Regards!!
Hi @Kaian,
Thanks a lot for your reply. With your hints, I was able to static-compile using the following on my system:
$ ./bootstrap.sh
$ CFLAGS='-static' \
LIBS='-ltinfo -lgpm' \
./configure --enable-unicode
$ make clean && make V=1
$ ldd src/sngrep
not a dynamic executable
$ src/sngrep -I tests/aaa.pcap -N
Dialog count: 6
It was interesting that I needed to add libtinfo
and libgpm
for
the linking stage to be successful on my system (Ubuntu 16.04 LTS),
while you didn't need it on Gentoo.
For the sake of completeness, I'm adding my system and library details below. Hopefully others reading this will find these useful.
As you'll see below, I'm on a fairly recent system (Ubuntu 16.04.4
LTS), and my libncurses*
versions all fairly recent!
$ cat /etc/lsb-release
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=16.04
DISTRIB_CODENAME=xenial
DISTRIB_DESCRIPTION="Ubuntu 16.04.4 LTS"
$ dpkg -l | awk '/libncurses/{print $2, $3}'
libncurses5:amd64 6.0+20160213-1ubuntu1
libncurses5-dev:amd64 6.0+20160213-1ubuntu1
libncursesw5:amd64 6.0+20160213-1ubuntu1
libncursesw5-dev:amd64 6.0+20160213-1ubuntu1
Thanks a lot once again.
Hi @Kaian,
It appears that static-compiling with OpenSSL additional require
libcrypto
and libdl
to be specified under LIBS
on Ubuntu
16.04!
Hope this helps someone. Thank you!
$ cat /etc/lsb-release
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=16.04
DISTRIB_CODENAME=xenial
DISTRIB_DESCRIPTION="Ubuntu 16.04.4 LTS"
$ CFLAGS=-static \
LIBS=-lssl -ltinfo -lgpm -lcrypto -ldl \
./configure --with-openssl --enable-unicode
$ make clean && make V=1
$ ldd src/sngrep
not a dynamic executable
$ src/sngrep -I tests/aaa.pcap -N
Dialog count: 6
Hi @gsbabil
Glad you managed to compile it successfully!!
You may need a couple extra libraries because your ncurses libraries are compiled with that dependencies, and as I mentioned in the previous comment, you need all the static versions of the libraries and their dependencies. In my box, ncurses has gmp disabled and tinfo is compiled inside the ncurses code, so I just needed the libncurses dependency.
For the record, if the library has a .pc file pkg-config
has a --static
flag that can help discovering depedencies:
$ pkg-config --static --libs openssl
-lssl -ldl -lz -lcrypto -ldl -lz
The project wiki is open to everyone, feel free to add there whatever information you feel could be helpful for anyone.
We can also close this issue if you don't need further assistance, feel free to reopen if you want to add extra information.
Regards!
Hi Everyone,
I took a stab at static compiling
sngrep
, but failed at the linking stage.I can get past the
configure
step with the following:But then
make
fails as shown below:Any help to static-compile
sngrep
will be greatly appreciated.Thanks a lot.