无法初始化服务器 - GTKmm 和 Cygwin
Unable to init server - GTKmm and 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用于工具链和cmake,在linux和MacOS中工作完美。我试图以相同的结果构建侏儒网站的示例。
主.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);
}
主窗口.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;
}
使用cygwin无法使用GTK,我可以弄清楚为什么它没有启动X11。我使用Mingw重建项目,并像魅力一样工作。
相关文章:
- Windows/Cygwin - 不能使用 pybind11 - 犯错误
- Windows 10-使用gtkmm-3.0库和g++[包括再现]的分段故障
- C++GTKMM gui循环依赖关系
- 在cygwin中运行c++脚本时发生错误
- 在cygwin中测试新的boost安装时出现cpp错误
- gtkmm 显示文件内容
- Gtkmm 会不断检查 Gtk::日历上的所选日期是否发生变化
- 如何配置Visual Studio Code以使用cygwin,cmake和gcc进行调试
- 使用 Gtkmm 以编程方式选择 Gtk::TextView 中的文本
- 如何在代码块中安装 gtkmm?
- 在 gtkmm 中异步加载图像
- Gtkmm 窗口为空白,不显示任何小部件或标题
- GTKMM:拍摄绘图区域的屏幕截图?
- 多线程 gtkmm 应用程序最简单的示例
- GTKMM:如何将键盘事件附加到绘图区域?
- Cygwin下的gcc 9.3.0预处理器:cmdline -Dname,但名称似乎未定义
- 错误:GTKMM 3.0 编译错误
- 使用 NVIDIA GPU 在 Cygwin 中链接 OpenCL 库时遇到问题
- 在Cygwin上链接Boost库
- 无法初始化服务器 - GTKmm 和 Cygwin