irontec / sngrep

Ncurses SIP Messages flow viewer
GNU General Public License v3.0
1.01k stars 189 forks source link

ncurses on NetBSD #369

Closed serxoz closed 3 years ago

serxoz commented 3 years ago

Hi!

I'm trying to compile in NetBSD. How can I tell the configure script that ncurses.h is in "/usr/pkg/include/ncurses/ncurses.h" ? ./configure stops with:

test: ==: unexpected operator
checking for ncurses.h... no
configure: error:  You need to have ncurses development files installed to compile sngrep.

Thank you in advance.

Kaian commented 3 years ago

Hi @serxoz !

Try adding the include path for headers in CFLAGS

CFLAGS="-I /usr/pkg/include/" ./configure

You may need to add path for libraries if there are not located in standard places too

CFLAGS="-I /usr/pkg/include/" LDFLAGS="-L /path/to/libraries/" ./configure

Hope it helps!

serxoz commented 3 years ago

Hi @Kaian

Thank you for your indication.

I've tried with this:

CFLAGS="-I /usr/pkg/include/ncurses/" LDFLAGS="-L /usr/pkg/lib/" ./configure

But returns the same error.

Here is the content of "/usr/pkg/include/ncurses/":

-rw-r--r--  1 root  wheel  82353 Jun 20 13:28 curses.h
-rw-r--r--  1 root  wheel   6886 Jun 20 13:28 cursesapp.h
-rw-r--r--  1 root  wheel  28037 Jun 20 13:28 cursesf.h
-rw-r--r--  1 root  wheel  19906 Jun 20 13:28 cursesm.h
-rw-r--r--  1 root  wheel   8738 Jun 20 13:28 cursesp.h
-rw-r--r--  1 root  wheel  49887 Jun 20 13:28 cursesw.h
-rw-r--r--  1 root  wheel   7415 Jun 20 13:28 cursslk.h
-rw-r--r--  1 root  wheel   2969 Jun 20 13:28 eti.h
-rw-r--r--  1 root  wheel   9791 Jun 20 13:28 etip.h
-rw-r--r--  1 root  wheel  18827 Jun 20 13:28 form.h
-rw-r--r--  1 root  wheel  12291 Jun 20 13:28 menu.h
-rw-r--r--  1 root  wheel   4248 Jun 20 13:28 nc_tparm.h
lrwxr-xr-x  1 root  wheel      8 Jun 20 13:28 ncurses.h -> curses.h
-rw-r--r--  1 root  wheel   4522 Jun 20 13:28 ncurses_dll.h
-rw-r--r--  1 root  wheel   4209 Jun 20 13:28 panel.h
-rw-r--r--  1 root  wheel  40457 Jun 20 13:28 term.h
-rw-r--r--  1 root  wheel   9112 Jun 20 13:28 term_entry.h
-rw-r--r--  1 root  wheel   3479 Jun 20 13:28 termcap.h
-rw-r--r--  1 root  wheel  14838 Jun 20 13:28 tic.h
-rw-r--r--  1 root  wheel   3185 Jun 20 13:28 unctrl.h

And here the content of "/usr/pkg/lib/":

ls -l /usr/pkg/lib/libncur*

-rw-r--r--  1 root  wheel  120904 Jun 20 13:28 /usr/pkg/lib/libncurses++.a
-rwxr-xr-x  1 root  wheel    1123 Jun 20 13:28 /usr/pkg/lib/libncurses++.la
lrwxr-xr-x  1 root  wheel      21 Jun 20 13:28 /usr/pkg/lib/libncurses++.so -> libncurses++.so.6.2.0
lrwxr-xr-x  1 root  wheel      21 Jun 20 13:28 /usr/pkg/lib/libncurses++.so.6 -> libncurses++.so.6.2.0
-rwxr-xr-x  1 root  wheel   86792 Jun 20 13:28 /usr/pkg/lib/libncurses++.so.6.2.0
-rw-r--r--  1 root  wheel  120632 Jun 20 14:14 /usr/pkg/lib/libncurses++w.a
-rwxr-xr-x  1 root  wheel    1149 Jun 20 14:14 /usr/pkg/lib/libncurses++w.la
lrwxr-xr-x  1 root  wheel      22 Jun 20 14:14 /usr/pkg/lib/libncurses++w.so -> libncurses++w.so.6.2.0
lrwxr-xr-x  1 root  wheel      22 Jun 20 14:14 /usr/pkg/lib/libncurses++w.so.6 -> libncurses++w.so.6.2.0
-rwxr-xr-x  1 root  wheel   65056 Jun 20 14:14 /usr/pkg/lib/libncurses++w.so.6.2.0
-rw-r--r--  1 root  wheel  699756 Jun 20 13:28 /usr/pkg/lib/libncurses.a
-rwxr-xr-x  1 root  wheel     968 Jun 20 13:28 /usr/pkg/lib/libncurses.la
lrwxr-xr-x  1 root  wheel      19 Jun 20 13:28 /usr/pkg/lib/libncurses.so -> libncurses.so.6.2.0
lrwxr-xr-x  1 root  wheel      19 Jun 20 13:28 /usr/pkg/lib/libncurses.so.6 -> libncurses.so.6.2.0
-rwxr-xr-x  1 root  wheel  404176 Jun 20 13:28 /usr/pkg/lib/libncurses.so.6.2.0
-rw-r--r--  1 root  wheel  813170 Jun 20 14:14 /usr/pkg/lib/libncursesw.a
-rwxr-xr-x  1 root  wheel     990 Jun 20 14:14 /usr/pkg/lib/libncursesw.la
lrwxr-xr-x  1 root  wheel      20 Jun 20 14:14 /usr/pkg/lib/libncursesw.so -> libncursesw.so.6.2.0
lrwxr-xr-x  1 root  wheel      20 Jun 20 14:14 /usr/pkg/lib/libncursesw.so.6 -> libncursesw.so.6.2.0
-rwxr-xr-x  1 root  wheel  438472 Jun 20 14:14 /usr/pkg/lib/libncursesw.so.6.2.0

Maybe the problem is that link from ncurses.h to curses.h. Seems like NetBSD don't fully support ncurses. Maybe I'm not getting it right.

Thank you again for your attention and help.

Kaian commented 3 years ago

If you enable unicode with ./configure --enable-unicode, theorically, sngrep configure.ac (the template used to generate configure script during bootstrap.sh), uses ncursesw6-config to configure the flags and libs for you.

Looks like you have ncursesw6.2 installed so these commands should display what will be used for CFLAGS and LDFLAGS when unicode is enabled:

# ncursesw6-config --cflags
-D_NETBSD_SOURCE -D_XOPEN_SOURCE=600 -I/usr/pkg/include/ncursesw

# ncursesw6-config --libs
-Wl,-R/usr/pkg/lib -L/usr/pkg/lib -Wl,-R/usr/pkg/lib -lncursesw

FTR: sngrep also uses form, panel and menu libraries that are usually shipped with ncurses.

serxoz commented 3 years ago

I've tried it both ways:

./configure --enable-unicode

and passing cflags with the output of ncursesw6-config:

CFLAGS="-D_NETBSD_SOURCE -D_XOPEN_SOURCE=600 -I/usr/pkg/include/ncursesw" \
LDFLAGS="-Wl,-R/usr/pkg/lib -L/usr/pkg/lib -Wl,-R/usr/pkg/lib -lncursesw" \
./configure

Both without success.

test: ==: unexpected operator
checking for ncurses.h... no
configure: error:  You need to have ncurses development files installed to compile sngrep.
Kaian commented 3 years ago

Sorry for the late response, I was on holidays.

I have no testing enviroment for NetBSD, but maybe we can get something from config.log Could you upload it to pastebin or something similar?

Thanks!

serxoz commented 3 years ago

No problem. I hope you had a good time on your holidays :D

Here it is: config.log

BTW I can provide a shell in a NetBSD system. In fact i'd like to use sngrep in this system ( I think you understand spanish :D) https://xinu.me/inscripcion.html

Kaian commented 3 years ago

From your config.log

configure:7053: checking for ncurses.h
configure:7053: gcc -c -D_NETBSD_SOURCE -D_XOPEN_SOURCE=600 -I/usr/pkg/include/ncursesw  conftest.c >&5
In file included from conftest.c:68:0:
/usr/pkg/include/ncursesw/ncurses.h:61:10: fatal error: ncurses/ncurses_dll.h: No such file or directory
 #include <ncurses/ncurses_dll.h>
          ^~~~~~~~~~~~~~~~~~~~~~~
compilation terminated.
configure:7053: $? = 1

Looks like ncurses is including another file that can't be found.

If I have some spare time, I'll request you a shell 0:-) Thanks for your patience!

EDIT: maybe we can add both include paths -I/usr/pkg/include/ncursesw -I/usr/pkg/include/ to CFLAGS

serxoz commented 3 years ago

Yeah! It works! :D

Now I've to figure out how to include GnuTLS and OpenSSL support but I suppose will be something similar, finding the libraries and including them in CFLAGS.

There is only one caveat, when i run it without arguments it returns this error:

Couldn't activate capture: BIOCSETIF failed: Device not configured

But if I specify the interface with -d option works fine.

Here is the ./configure execution if you like to document it:

CFLAGS="-D_NETBSD_SOURCE -D_XOPEN_SOURCE=600 -I/usr/pkg/include/ncursesw -I/usr/pkg/include/" \
LDFLAGS="-Wl,-R/usr/pkg/lib -L/usr/pkg/lib -Wl,-R/usr/pkg/lib -lncursesw" \
./configure

Thank you for your attention and patience. I use sngrep almost every day on linux and I don't know what it would be like to have to go back to Wireshark...

P.D.: I am setting a service up based on Elio's article "call me to my email" in xinu.me :D

Kaian commented 3 years ago

Yay! Nice!

About the error, that's probably because the default capture device is any and not all environments are able to use this virtual device. You can change default capture device in sngreprc file.

Feel free to add compile intructions or other documentation in the wiki for others or your future self. I think it's open so everyone can edit its pages.

Glad to know sngrep helped you! Feel free to close the issue if you managed to compile with your required flags.

Regards!