RAT
RAT

Reputation: 239

Why do i get the error that spawn_async_with_pipes has no matching function?

I'm encountering an issue while using the Glib::spawn_async_with_pipes function in my C++ code. Despite verifying the function's existence using the nm -D /lib/x86_64-linux-gnu/libglibmm-2.4.so | grep "spawn_async_with_pipes" command, I'm still getting a compilation error

the error that I am getting

main.cpp:44:37: error: no matching function for call to ‘spawn_async_with_pipes(const char [2], <brace-enclosed initializer list>, Glib::SpawnFlags, sigc::slot<void, int, int>, GPid*, Glib::RefPtr<Glib::IOChannel>*, Glib::RefPtr<Glib::IOChannel>*, std::nullptr_t, std::nullptr_t)’
   44 |         Glib::spawn_async_with_pipes(".",   // Working directory
      |         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
   45 |                                      {"bash", "-c", command}, // Command to execute
      |                                      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   46 |                                      Glib::SPAWN_DEFAULT,    // Spawn flags
      |                                      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   47 |                                      sigc::slot<void, Glib::Pid, int>(
      |                                      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   48 |                                          sigc::mem_fun(*this, &TerminalWindow::on_subprocess_exit)), // Callback
      |                                          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   49 |                                      &pid,    // Process ID
      |                                      ~~~~~~~~~~~~~~~~~~~~~~
   50 |                                      &stdin_channel, // Standard input channel
      |                                      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   51 |                                      &stdout_channel,  // Standard output channel
      |                                      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   52 |                                      nullptr, // Standard error channel
      |                                      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   53 |                                      nullptr  // Main context
      |                                      ~~~~~~~~~~~~~~~~~~~~~~~~
   54 |         );

I am compiling using g++ main.cpp pkg-config --cflags --libs gtkmm-3.0 glib-2.0 gio-2.0 and the code that is causing this problem is

    void handle_command() {
        Gtk::TextIter start, end;
        terminal_buffer->get_bounds(start, end);
        std::string command = terminal_buffer->get_text(start, end);

        // ... Create pipes for input and output
        Glib::RefPtr<Glib::IOChannel> stdin_channel, stdout_channel;
        int exit_status = 0;

        // Spawn the subprocess with pipes for input and output
        Glib::spawn_async_with_pipes(".",   // Working directory
                                     {"bash", "-c", command}, // Command to execute
                                     Glib::SPAWN_DEFAULT,    // Spawn flags
                                     sigc::slot<void, Glib::Pid, int>(
                                         sigc::mem_fun(*this, &TerminalWindow::on_subprocess_exit)), // Callback
                                     &pid,    // Process ID
                                     &stdin_channel, // Standard input channel
                                     &stdout_channel,  // Standard output channel
                                     nullptr, // Standard error channel
                                     nullptr  // Main context
        );

Upvotes: 0

Views: 73

Answers (0)

Related Questions