Is there any way to create a GUI application in C without any operating system?

huangapple go评论66阅读模式
英文:

Is there any way to create a GUI application in C without any operating system?

问题

I'm developing a mini operating system for my PC and was wondring is it possible to create a mini operating system in C that uses GUI and if it's possible to compile it using grub? I dont know what libary's i should use or if it's even possible.

I tryed this code generated from ChatGPT but it didnt let me compile it.

#include <gtk/gtk.h>

int main(int argc, char *argv[]) {
  gtk_init(&argc, &argv);

  GtkWidget *window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
  gtk_window_set_title(GTK_WINDOW(window), "GUI Bootloader");
  gtk_window_set_default_size(GTK_WINDOW(window), 300, 200);

  GtkWidget *label = gtk_label_new("Welcome to the bootloader!");
  GtkWidget *button = gtk_button_new_with_label("Boot");

  GtkWidget *box = gtk_box_new(GTK_ORIENTATION_VERTICAL, 5);
  gtk_box_pack_start(GTK_BOX(box), label, TRUE, TRUE, 0);
  gtk_box_pack_start(GTK_BOX(box), button, TRUE, TRUE, 0);

  gtk_container_add(GTK_CONTAINER(window), box);

  g_signal_connect(G_OBJECT(window), "destroy", G_CALLBACK(gtk_main_quit), NULL);
  g_signal_connect(G_OBJECT(button), "clicked", G_CALLBACK(gtk_main_quit), NULL);

  gtk_widget_show_all(window);

  gtk_main();

  return 0;
}

I tryed to install the libary GTK but didnt work.

英文:

I'm developing a mini operating system for my PC and was wondring is it possible to create a mini operating system in C that uses GUI and if it's possible to compile it using grub? I dont know what libary's i should use or if it's even possible.

I tryed this code generated from ChatGPT but it didnt let me compile it.

#include &lt;gtk/gtk.h&gt;

int main(int argc, char *argv[]) {
  gtk_init(&amp;argc, &amp;argv);

  GtkWidget *window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
  gtk_window_set_title(GTK_WINDOW(window), &quot;GUI Bootloader&quot;);
  gtk_window_set_default_size(GTK_WINDOW(window), 300, 200);

  GtkWidget *label = gtk_label_new(&quot;Welcome to the bootloader!&quot;);
  GtkWidget *button = gtk_button_new_with_label(&quot;Boot&quot;);

  GtkWidget *box = gtk_box_new(GTK_ORIENTATION_VERTICAL, 5);
  gtk_box_pack_start(GTK_BOX(box), label, TRUE, TRUE, 0);
  gtk_box_pack_start(GTK_BOX(box), button, TRUE, TRUE, 0);

  gtk_container_add(GTK_CONTAINER(window), box);

  g_signal_connect(G_OBJECT(window), &quot;destroy&quot;, G_CALLBACK(gtk_main_quit), NULL);
  g_signal_connect(G_OBJECT(button), &quot;clicked&quot;, G_CALLBACK(gtk_main_quit), NULL);

  gtk_widget_show_all(window);

  gtk_main();

  return 0;
}

I tryed to install the libary GTK but didnt work.

答案1

得分: 2

I'll provide the translation for the text you provided:

有没有办法在没有任何操作系统的情况下创建一个C语言的GUI应用程序?

没有。使复杂硬件工作的软件被称为操作系统。您必须使用现有的操作系统或提供自己的操作系统。

对于非常简单的硬件,您可以编写执行专用任务的软件,我们可能不会称这样的软件为操作系统。但是,对于在典型的通用计算机上运行的软件,它管理磁盘驱动器、显示器、键盘等等,我们将称这个软件,或者至少是其中的一部分,为操作系统。必须有一些软件来管理中断、管理从设备发送和接收的数据等等。

英文:

> Is there any way to create a GUI application in C without any operating system?

No. The software that makes complicated hardware work is called an operating system. You must either use an existing operating system or provide your own.

For very simple hardware, you can write software that does dedicated tasks, and we might not call such software an operating system. However, for software that runs on a typical general-purpose computer and that manages the disk drives, the display, the keyboard, and so on, we are going to call that software, or at least part of it, the operating system. There must be some software that manages interrupts, manages data sent to and from the devices, and so on.

huangapple
  • 本文由 发表于 2023年4月7日 00:25:45
  • 转载请务必保留本文链接:https://go.coder-hub.com/75951724.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定