Невозможно инициализировать сервер - GTKmm и Cygwin

У меня есть простая программа, которая работает с GTKmm с C++, я пытаюсь собрать на Windows и запустить его. Я могу создать "легко", но когда я запускаю его, я получаю следующее сообщение:

Unable to init server: Could not connect to 127.0.0.1: Connection refused

(MyProgram:12624): Gtk-WARNING **: cannot open display:

Я использую GTKmm 3, Cygwin для toolchain и cmake, в Linux и MacOs работают отлично. Я попытался создать пример сайта гнома с тем же результатом.

main.cpp

#include <iostream>
#include <gtkmm.h>
#include "App/Desktop/Controller/Themes/Default.hpp"
#include "App/Desktop/Controller/MainWindow.hpp"

int main(int argc, char *argv[]){
  auto app = Gtk::Application::create(argc, argv, "my.application");

  /**
   * Create the MainWindow
   */
  window = new MainWindow();
  //window->show();

  /**
   * Load the Theme of Application
   */
  Default theme;
  theme.Load();

  app->run(*window);
}

MainWindow.hpp

#include <iostream>
#include "MainWindow.hpp"

MainWindow::MainWindow() : Gtk::Window(), ui(new Ui::MainWindow()) {
    ui->setupUi(this);

    this->set_size_request(600, 500);
    this->refresh();

    this->ui->open.signal_button_press_event().connect(sigc::mem_fun(*this,  &MainWindow::Open));
    this->ui->quit.signal_button_press_event().connect(sigc::mem_fun(*this,  &MainWindow::Quit));
    this->ui->about.signal_button_press_event().connect(sigc::mem_fun(*this, &MainWindow::About));
}

MainWindow::~MainWindow() {
    delete ui;
}

/**
 * Display all file avaliables to the User
 */
void MainWindow::refresh() {
    /**
     * Clear the Container and Free Memory
     */
    std::vector<Gtk::Widget*> childrens = ui->container.get_children();
    for(Gtk::Widget *child : childrens){
        ui->container.remove(*child);
        delete child;
    }

    /**
     * Add the New Elements to the Grid
     */
    int column = 3, lines;
    lines = (0 / column) + 1;
    lines = lines == 1 ? 3 : lines;
    for (int i = 0; i < lines; ++i) {
        for (int j = 0; j < column; ++j) {
                Gtk::Grid *empty = new Gtk::Grid();
                empty->set_name("companyWhiteCert");
                empty->set_visible(true);
                empty->set_hexpand(true);
                empty->set_vexpand(true);
                ui->container.attach(*empty, j, i, 1, 1);

        }
    }

}

/**
 * TopBar Menu Event
 */

/**
 * Open a New File
 * @param event
 * @return
 */
bool MainWindow::Open(GdkEventButton *event) {
    std::cout << "Open" << std::endl;
    return true;
}

/**
 * Quit the Application
 * @param event
 * @return
 */
bool MainWindow::Quit(GdkEventButton* event) {
    this->hide();
    return true;
}

/**
 * Apen About Menu
 * @param event
 * @return
 */
bool MainWindow::About(GdkEventButton *event) {
    std::cout << "About" << std::endl;
    return true;
}

1 ответ

Использование Cygwin было невозможно использовать GTK, я могу понять, почему он не запускает X11. Я перестраиваю проект, используя Mingw, и работаю как шарм.

Другие вопросы по тегам