Skip to content
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

mtr (GTK interface) doesn't work as expected on win32 #202

Open
zcattacz opened this issue Jun 4, 2017 · 4 comments
Open

mtr (GTK interface) doesn't work as expected on win32 #202

zcattacz opened this issue Jun 4, 2017 · 4 comments

Comments

@zcattacz
Copy link

zcattacz commented Jun 4, 2017

<cut & pasted from #199>

I also tried to compile it with GTK+, at first am trapped at linking stage for mtr.exe,

$ make
make  all-am
make[1]: Entering directory '/home/Ben/mtr/mtr-master'
  CCLD     mtr.exe
/c/Program Files/GTK+/lib: file not recognized: Is a directory
collect2: error: ld returned 1 exit status
make[1]: *** [Makefile:788: mtr.exe] Error 1
make[1]: Leaving directory '/home/Ben/mtr/mtr-master'
make: *** [Makefile:642: all] Error 2

make -n

echo "  CCLD    " mtr.exe;
i686-pc-msys-gcc 
-I'/c/Program Files/GTK+/include' -I'/c/Program Files/GTK+/include/gtk-2.0' 
-I'/c/Program Files/GTK+/include/glib-2.0' -I'/c/Program Files/GTK+/lib/glib-2.0/include' 
-I'/c/Program Files/GTK+/include/cairo' -I'/c/Program Files/GTK+/include/pango-1.0' 
-I'/c/Program Files/GTK+/lib/gtk-2.0/include' -I'/c/Program Files/GTK+/include/gdk-pixbuf-2.0' 
-I'/c/Program Files/GTK+/include/gail-1.0' -I'/c/Program Files/GTK+/include/atk-1.0' 
-I'/c/Program Files/GTK+/include/gio-win32-2.0' -I'/c/Program Files/GTK+/include/freetype2' 
 -g -O2 -Wall -Wno-pointer-sign   
-o mtr.exe 
ui/mtr-mtr.o ui/mtr-net.o ui/mtr-cmdpipe.o ui/mtr-dns.o ui/mtr-raw.o ui/mtr-split.o 
ui/mtr-display.o ui/mtr-report.o ui/mtr-select.o ui/mtr-utils.o packet/mtr-cmdparse.o   
ui/mtr-asn.o ui/mtr-curses.o ui/mtr-gtk.o 
/c/Program\ Files/GTK+/lib  -lresolv -lncurses -lm

GTK_LIBS is set to a directory. I corrected my brainless error, moved all the directory to GTK_CFLAGS=-L'/c/Program Files/...' But I am still getting a lot of compiling error undefined reference to g_type_check_instance_cast etc. like below:

$ i686-pc-msys-gcc -I'/c/Program Files/GTK+/include' -I'/c/Program Files/GTK+/include/gtk-2.0' -I'/c/Program Files/GTK+/include/glib-2.0' -I'/c/Program Files/GTK+/lib/glib-2.0/include' -I'/c/Program Files/GTK+/include/cairo' -I'/c/Program Files/GTK+/include/pango-1.0' -I'/c/Program Files/GTK+/lib/gtk-2.0/include' -I'/c/Program Files/GTK+/include/gdk-pixbuf-2.0' -I'/c/Program Files/GTK+/include/gail-1.0' -I'/c/Program Files/GTK+/include/atk-1.0' -I'/c/Program Files/GTK+/include/gio-win32-2.0' -I'/c/Program Files/GTK+/include/freetype2' -L'/c/Program Files/GTK+/lib'  -g -O2 -Wall -Wno-pointer-sign   -o mtr.exe ui/mtr-mtr.o ui/mtr-net.o ui/mtr-cmdpipe.o ui/mtr-dns.o ui/mtr-raw.o ui/mtr-split.o ui/mtr-display.o ui/mtr-report.o ui/mtr-select.o ui/mtr-utils.o packet/mtr-cmdparse.o   ui/mtr-asn.o ui/mtr-curses.o ui/mtr-gtk.o -L'/c/Program Files/GTK+/lib'  -lresolv -lncurses -lm -lgtk-win32-2.0
ui/mtr-gtk.o: In function `Host_activate':
/home/Ben/mtr/mtr-master/ui/gtk.c:249: undefined reference to `g_type_check_instance_cast'
/home/Ben/mtr/mtr-master/ui/gtk.c:254: undefined reference to `g_type_check_instance_cast'
/home/Ben/mtr/mtr-master/ui/gtk.c:256: undefined reference to `g_type_check_instance_cast'
/home/Ben/mtr/mtr-master/ui/gtk.c:257: undefined reference to `g_type_check_instance_cast'
/home/Ben/mtr/mtr-master/ui/gtk.c:258: undefined reference to `g_type_check_instance_cast'
ui/mtr-gtk.o:/home/z/mtr/mtr-master/ui/gtk.c:198: more undefined references to `g_type_check_instance_cast' follow
ui/mtr-gtk.o: In function `float_formatter':
/home/Ben/mtr/mtr-master/ui/gtk.c:358: undefined reference to `g_object_set'
ui/mtr-gtk.o: In function `percent_formatter':
/home/Ben/mtr/mtr-master/ui/gtk.c:372: undefined reference to `g_object_set'

After linked a lot of lib like below by hand it successfully compiled:

 GTK_LIBS += -lgtk-win32-2.0 -lgobject-2.0 -lgio-2.0  -lglib-2.0 -lgdk_pixbuf-2.0

But the compiled binary doesn't work. giving error alert asking for a -mms-bitfields switch, so my final CFLAGS for GTK become:

export GTK_CFLAGS="-mms-bitfields -I'/c/Program Files/GTK+/include' -I'/c/Program Files/GTK+/include/gtk-2.0' -I'/c/Program Files/GTK+/include/glib-2.0' -I'/c/Program Files/GTK+/lib/glib-2.0/include' -I'/c/Program Files/GTK+/include/cairo' -I'/c/Program Files/GTK+/include/pango-1.0' -I'/c/Program Files/GTK+/lib/gtk-2.0/include' -I'/c/Program Files/GTK+/include/gdk-pixbuf-2.0' -I'/c/Program Files/GTK+/include/gail-1.0' -I'/c/Program Files/GTK+/include/atk-1.0' -I'/c/Program Files/GTK+/include/gio-win32-2.0' -I'/c/Program Files/GTK+/include/freetype2' -L'/c/Program Files/GTK+/lib'"

After all these tinkering, the compiling completed without error, but the application doesn't work as expected. The UI is functional, and user interaction is ok. but it doesn't do the job. there is no data after setting the host, [restart] & [pause], console shows:

MINGW32 ~/mtr/mtr-master
$ ./mtr --gtk

(mtr.exe:6132): GLib-WARNING **: g_io_channel_unix_new: 5 is neither a file descriptor or a socket.

(mtr.exe:6132): GLib-CRITICAL **: g_io_add_watch_full: assertion `channel != NULL' failed

(mtr.exe:6132): GLib-WARNING **: g_io_channel_unix_new: 7 is neither a file descriptor or a socket.

(mtr.exe:6132): GLib-CRITICAL **: g_io_add_watch_full: assertion `channel != NULL' failed

Not sure what can be done next to get this right...

<cut paste from #199>
PS: my win32 GTK is gtk+-bundle_2.24.10-20120208_win32 recenetly downloaded by RGtk.
I can't imagine msys2 or cygwin users from Windows platform be such a fan of GTK+ to gone through all these pains to compile their GTK enabled mtr... I am compiling GTK simply because its claimed as supported and I never saw it before. Anyway I am quite happy with the current ncurses version status.
Thanks for creating this nice piece of software, and offering it to public for free.

@rewolff
Copy link
Collaborator

rewolff commented Jun 4, 2017

OK. To me this becomes more readable than among the "mess" of different things in the other issue. Thus improving the chances of finding a fix....

The GTK warnings are probably about the "pipe" from mtr-packet to the mtr-gui. In curses-mode those are used in an mtr-internal select call, but in GTK, these are passed to "..add_watch.." and then gtk is supposed to watch those FDs and dispatch to the code to handle the IO that comes in.

The question is: Did we create the wrong type of filedescriptor? Or does GTK on Windows simply not support pipes as an object to watch?

@zcattacz
Copy link
Author

zcattacz commented Jun 4, 2017 via email

@zcattacz
Copy link
Author

zcattacz commented Jun 4, 2017

Linked all the lib in gtk+/lib,

 83 if WITH_GTK
 84 mtr_SOURCES += ui/gtk.c
 85 GTK_LIBS += -lgtk-win32-2.0 -lgobject-2.0 -lgio-2.0  -lglib-2.0 -lgdk_pixbuf-2.0 \
 86             -latk-1.0 -lcairo -lexpat -lfontconfig \
 87             -lfreetype -lgailutil -lgdk-win32-2.0 -lgmodule-2.0 \
 88             -lgthread-2.0 -lintl -llibpng -lpango-1.0 \
 89             -lpangocairo-1.0 -lpangoft2-1.0 -lpangowin32-1.0 -lzdll
 90 endif

same error.

$ ./mtr --gtk

(mtr.exe:10448): GLib-WARNING **: g_io_channel_unix_new: 5 is neither a file descriptor or a socket.

(mtr.exe:10448): GLib-CRITICAL **: g_io_add_watch_full: assertion `channel != NULL' failed

(mtr.exe:10448): GLib-WARNING **: g_io_channel_unix_new: 7 is neither a file descriptor or a socket.

(mtr.exe:10448): GLib-CRITICAL **: g_io_add_watch_full: assertion `channel != NULL' failed

@rewolff
Copy link
Collaborator

rewolff commented Jun 4, 2017

Sorry. forgot to reply to tell you that wouldn't help.

Under Unix the philosophy is: "everything is a file". So you open a serial port by opening /dev/ttyUSB0, /dev/ttyS0 or /dev/ttyAMA0. For basic operations, that's "a file descriptor" that works just like any other. There are a few extra things that you can do through ioctl, but for everything else it just works.

On MSwindows, there is a special API for serial ports. what you get is a serial port handle, and that might not work everywhere a normal file handle works.

The "serial" above is just an example.

In the case at hand, the g_io_add_watch_full function seems to expect a file descriptor or a socket. The handle, 5, apparently does not qualify. It is a pipe to the sub-program "mtr-packet". So... Either g_io_add_watch_full needs to be expanded for the "special" case where the descriptor refers to a pipe, or mtr needs to be modified to make the pipe work as a file descriptor or a socket. (probably "socket").

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants