After a couple of rounds of troubleshooting I was able to compile GTK source code in Visual Studio with no errors. I followed a procedure not too dissimilar to 'How to configure gtk on Visual studio 2010' . The code is as follows,
#include <gtk-2.0\gtk\gtk.h>
#pragma comment(linker, "/SUBSYSTEM:windows /ENTRY:mainCRTStartup")
int main(int argc, char* argv[])
{
GtkWidget* window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
gtk_init(&argc, &argv);
gtk_widget_set_usize(window, 300, 200);
g_signal_connect(G_OBJECT(window), "destroy", G_CALLBACK(gtk_main_quit), NULL);
gtk_window_set_title(GTK_WINDOW(window), "GTK+ with VS2010");
gtk_widget_show(window);
gtk_main();
return 0;
}
However on starting the code no window appears. Visual Studio simply indicates the solution is running but no window appears. Any ideas?
There's problem here:
GtkWidget* window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
gtk_init(&argc, &argv);
You should call gtk_init
before creating any windows:
Call this function before using any other GTK+ functions in your GUI applications. It will initialize everything needed to operate the toolkit and parses some standard command line options.
Try:
gtk_init(&argc, &argv);
GtkWidget* window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.