Re: need some advice for gtkmm on windows



Kasper Peeters wrote:
> I am in the process of porting a POSIX application to Windows, and
> would like some advice on what is currently the best route to take.
> 
> The application uses fork/execvp/select/pipe, so my first guess is
> that I should probably use cygwin instead of mingw. However, I would
> still like to use the win32 backend of gtk, rather than the x11
> one. Is that at present possible & reliable at all? If not, are there
> any other options besides cygwin to help me get around the unix
> process/pipe handling on windows?

I don't know about gtkmm, but the C API of gtk is very usable on native
windows.  We use it for GPA, for example.

You could implement these functions using the native Windows API of course.
It's a *lot* of work, though.  If you decide to do this, and need example
code, the whole gnupg application suite (gnupg2, gpgme, dirmngr, etc) is
ported to W32 using this strategy.

Just to give you an example of what this means: You can't select on a pipe in
Windows: Probing for readability involves reading at least one byte.  This
means you need to buffer data between the "select" call and the actual
read/write call.  Another example: To control which file descriptors are
inherited when spawning a subprocess, you need an intermediate helper process
that sets up the environment.

On the other hand, as this is the gtkmm mailing list, why don't you just use
glib?  glib contains the code to deal with all these problems as well.  The
GIOChannel implementation implements select on sockets and pipes and there is
a spawn implementation using the above helper process.  I know the gnupg/gpgme
and the glib code for w32 native, and they are conceptually identical.

My strong advice is to use glib for everything if portability is a concern.
In gnupg we have special overriding concerns (security), but we are paying a
price in duplicating and maintaining the Windows helper code.

Thanks,
Marcus


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]