Re: spawn_async_with_pipes on windows using mingw (code atached)



On Fri, 2008-09-26 at 17:59 -0300, Paulo Flabiano Smorigo wrote:
> Hi everybody,
> 
> I'm still trying to compile spawn_async_with_pipes on windows. Now I
> created a little source that can help to solve the problem.
> 
> I use the following command to compile (using gtkmm for windows
> libraries):
> i586-mingw32msvc-g++ Player.cpp `pkg-config --cflags --libs gtkmm-2.4`
> -o app.exe
> 
> The code:
> #include <iostream>
> #include <gtkmm.h>
> #include <glibmm.h>
> 
> class Player : public Gtk::Window
> {
> public:
>     Player();
>     virtual ~Player();
> };
> 
> Player::Player()
> {
>     int _pid = 0;
>     int _stdin = 0;
>     int _stdout = 0;
>     int _stderr = 0;
> 
>     char *vec[5];
>     vec[0] = "\"c:/mplayer/mplayer.exe\"";
>     vec[1] = "\"-quiet\"";
>     vec[2] = "\"-slave\"";
>     vec[3] = "\"-idle\"";
>     vec[4] = "\"c:/mplayer/truthhappens.ogg\"";
>     
>     Glib::spawn_async_with_pipes("\"c:/\"", (char**) vec,
> Glib::SpawnFlags(0), sigc::slot<void>(), &_pid, &_stdin, &_stdout,
> &_stderr);
> 
>     std::cout << "PID:    " << _pid << std::endl; 
>     std::cout << "STDIN:  " << _stdin << std::endl; 
>     std::cout << "STDOUT: " << _stdout << std::endl; 
>     std::cout << "STDERR: " << _stderr << std::endl; 
>     show_all_children();
> }
> 
> Player::~Player()
> {
> }
> 
> int main(int argc, char *argv[])
> {
>     Gtk::Main kit(argc, argv);
>     Player player;
>     Gtk::Main::run(player);
> 
>     return 0;
> }
> 
> 
> And the error:
> Player.cpp: In constructor `Player::Player()':
> Player.cpp:26: error: no matching function for call to
> `spawn_async_with_pipes(const char[6], char**, Glib::SpawnFlags,
> sigc::slot<void, sigc::nil, sigc::nil, sigc::nil, sigc::nil,
> sigc::nil, sigc::nil, sigc::nil>, int*, int*, int*, int*)'
> /opt/gtk28win/include/glibmm-2.4/glibmm/spawn.h:147: note: candidates
> are: void Glib::spawn_async_with_pipes(const std::string&, const
> Glib::ArrayHandle<std::string,
> Glib::Container_Helpers::TypeTraits<std::string> >&, const
> Glib::ArrayHandle<std::string,
> Glib::Container_Helpers::TypeTraits<std::string> >&, Glib::SpawnFlags,
> const sigc::slot<void, sigc::nil, sigc::nil, sigc::nil, sigc::nil,
> sigc::nil, sigc::nil, sigc::nil>&, void**, int*, int*, int*)
> /opt/gtk28win/include/glibmm-2.4/glibmm/spawn.h:156: note:
> void Glib::spawn_async_with_pipes(const std::string&, const
> Glib::ArrayHandle<std::string,
> Glib::Container_Helpers::TypeTraits<std::string> >&, Glib::SpawnFlags,
> const sigc::slot<void, sigc::nil, sigc::nil, sigc::nil, sigc::nil,
> sigc::nil, sigc::nil, sigc::nil>&, void**, int*, int*, int*)
> 
> 
> Thanks in advance for the help...

PIDs are not simply integers on Windows, but pointers in fact (a HANDLE
for the created process). Glib provides the type Glib::Pid which should
be used for PIDs. This is an integer on linux, and a pointer on Windows.
So, try changing the type of _pid from int to Glib::Pid.

Furthermore, I don't think you can pass a simple C array as a
Glib::ArrayHandle to the spawn function (it would not know how many
entries there are in the array). Try using an STL container, such as
std::vector, instead:

Replace char *vec[5] by std::vector<std::string> vec(5)

> Paulo Flabiano Smorigo

Armin

> _______________________________________________
> gtkmm-list mailing list
> gtkmm-list gnome org
> http://mail.gnome.org/mailman/listinfo/gtkmm-list



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