Source: http://blog.sina.com.cn/s/blog_a6fb6cc901017ygy.html
Windows GTK + Environment Setup
Recently to do some of the interface, but the Microsoft provided the Class library MFC is not very familiar with the package of a lot of Windows API more trouble, and then think of other ways! QT, GTK + originally wanted to learn QT, QT cross-platform, document also more points, the use is more extensive. But the QT plugin has not been downloaded, then learn to learn GTK +!
Search on the Internet a lot about the Windows GTK + environment to build the method, but a lot of said is not very clear, so they refer to some documents, on the official website download the required environment files, set up a GTK + environment. And a detailed record of the following is the main content.
download GTK all-in-one Bundles Pack
All right, let's get down to it! Start our Windows GTK + Environment setup. It is mainly divided into the following steps:
1) go to the official website www.gtk.org start learning about GTK + content.
GTK + Environment Setup (detailed) "Name=" image_operate_34581347010438522 "alt=" Windows GTK + Environment (detailed) "Src=" http://s1.sinaimg.cn/middle/ a6fb6cc9tc919061a1840&690 "width=" 470 "height=" 254 "real_src=" http://s1.sinaimg.cn/middle/ a6fb6cc9tc919061a1840&690 ">
2) click "Download" to go to the download page and find your own Windows corresponding environment Win32 or Win64 link, click to enter.
GTK + Environment Setup (detailed) "Name=" image_operate_41151347010438190 "alt=" Windows GTK + Environment (detailed) "Src=" http://s10.sinaimg.cn/middle/ a6fb6cc9tc9192a8b7879&690 "width=" 359 "height=" "real_src=" http://s10.sinaimg.cn/middle/ a6fb6cc9tc9192a8b7879&690 ">
3) To download, unzip, and organize the individual files, it is not very convenient, so you can choose a "all-in-one bundles" link, click to download.
GTK + Environment Setup (detailed) "Name=" image_operate_91341347010437105 "alt=" Windows GTK + Environment (detailed) "Src=" http://s7.sinaimg.cn/middle/ a6fb6cc9tc9192abf0f16&690 "real_src=" http://s7.sinaimg.cn/middle/a6fb6cc9tc9192abf0f16&690 ">
4) after the download is successful, unzip to any directory below, I choose "E:\Visual studio\gtk env", that is the GTK env (GTK environment) in the VS Engineering directory (not the installation directory),
After the decompression is complete, you can see some directory folders, including: Bin, etc, include, lib, man, manifest, share, SRC. Where the bin directory contains a number of executable files and dynamic link library, the Lib directory mainly contains some library files, include mainly contains some header files.
Setting Environment Variables
1) Configure the environment variable path
As I chose, add "E:\Visual studio\gtk env\bin" to the environment variable "Path". The bin directory contains the DLL files required by the runtime, which also includes the Gtk-demo.exe sample program.
GTK + Environment Setup (detailed) "Name=" image_operate_65861347010275435 "alt=" Windows GTK + Environment (detailed) "Src=" http://s1.sinaimg.cn/middle/ a6fb6cc9tc91940c6c470&690 "real_src=" http://s1.sinaimg.cn/middle/a6fb6cc9tc91940c6c470&690 ">
2) test Run
Run the "E:\Visual studio\gtk env\bin\gtk-demo.exe" sample program to display the following program interface.
GTK + Environment Setup (detailed) "Name=" image_operate_54421347012076793 "alt=" Windows GTK + Environment (detailed) "Src=" http://s15.sinaimg.cn/middle/ a6fb6cc9tc9198255af4e&690 "Width=" 616 "height=" 313 "real_src=" http://s15.sinaimg.cn/middle/ a6fb6cc9tc9198255af4e&690 ">
Setting the VS2008 compilation environmentset additional Include Directories
Right-click on the project, select Properties->c/c++-> general, add included directories, adding the Include folder under the GTK + directory and all folders in the Include folder, and the two include folders in the subfolders of the Lib folder, as shown in.
GTK + Environment Setup (detailed) "Name=" image_operate_30441347012075155 "alt=" Windows GTK + Environment (detailed) "Src=" http://s7.sinaimg.cn/middle/ a6fb6cc9tc919825a0876&690 "width=" 575 "height=" 339 "real_src=" http://s7.sinaimg.cn/middle/ a6fb6cc9tc919825a0876&690 ">
GTK + Environment Setup (detailed) "Name=" image_operate_92221347012071372 "alt=" Windows GTK + Environment (detailed) "Src=" http://s12.sinaimg.cn/middle/ a6fb6cc9tc9198261062b&690 "width=" 444 "height=" 311 "real_src=" http://s12.sinaimg.cn/middle/ a6fb6cc9tc9198261062b&690 ">
set up additional library directories
Go to the Library file view and add the Lib folder of the GTK + directory. To set up an additional library directory: Select the Add-in library directory, general---linker, and the Lib folder under the GTK + directory, as shown in.
GTK + Environment Setup (detailed) "Name=" image_operate_55331347012074423 "alt=" Windows GTK + Environment (detailed) "Src=" http://s16.sinaimg.cn/middle/ a6fb6cc9tc91990fae18f&690 "width=" 557 "height=" 346 "real_src=" http://s16.sinaimg.cn/middle/ a6fb6cc9tc91990fae18f&690 ">
GTK + Environment Setup (detailed) "Name=" image_operate_65401347012074254 "alt=" Windows GTK + Environment (detailed) "Src=" http://s7.sinaimg.cn/middle/ a6fb6cc9tc91990e95466&690 "real_src=" http://s7.sinaimg.cn/middle/a6fb6cc9tc91990e95466&690 ">
To add an additional dependency
New C + + Empty Project, additional dependencies, input--------------------"E:\Visual studio\gtk env\lib" All. lib files in the directory are placed in additional dependencies, including: Atk-1.0.lib, Cairo.lib, Expat.lib, Fontconfig.lib, Freetype.lib, Gailutil.lib, Gdk_ Pixbuf-2.0.lib, Gdk-win32-2.0.lib, Gio-2.0.lib, Glib-2.0.lib, Gmodule-2.0.lib, Gobject-2.0.lib, Gthread-2.0.lib, Gtk-win32-2.0.lib, Intl.lib, Libpng.lib, Pango-1.0.lib,
Pangocairo-1.0.lib, Pangoft2-1.0.lib, Pangowin32-1.0.lib, Zdll.lib.
GTK + Environment Setup (detailed) "Name=" image_operate_91851347012073969 "alt=" Windows GTK + Environment (detailed) "Src=" http://s7.sinaimg.cn/middle/ a6fb6cc9tc91998baf6f6&690 "width=" 364 "height=" 488 "real_src=" http://s7.sinaimg.cn/middle/ a6fb6cc9tc91998baf6f6&690 ">
GTK + Environment Setup (detailed) "Name=" image_operate_87211347012060063 "alt=" Windows GTK + Environment (detailed) "Src=" http://s6.sinaimg.cn/middle/ a6fb6cc9tc91998ba6f35&690 "width=" 442 "height=" 338 "real_src=" http://s6.sinaimg.cn/middle/ a6fb6cc9tc91998ba6f35&690 ">
Test
Create a new CPP file and write the following code to run the configuration successfully.
#include
int main (int argc, char *argv[])
{
Gtkwidget *window;
Gtkwidget *label;
Initializing the GTK + library
Gtk_init (&ARGC, &ARGV);
Creating the main window
window = Gtk_window_new (gtk_window_toplevel);
Set Window size
Gtk_widget_set_size_request (window,300,300);
Set Title
Gtk_window_set_title (Gtk_window (window), "Hello World");
Stop the main GTK + loop when the window is about to be destroyed
G_signal_connect (window, "Destroy", G_callback (Gtk_main_quit), NULL);
Create a "Hello World" label
Label = Gtk_label_new ("Hello, World");
Add a label to the main window
Gtk_container_add (Gtk_container (window), label);
All elements in the Settings window are visible
Gtk_widget_show_all (window);
Start the main loop and let it rest there until the application shuts down
Gtk_main ();
return 0;
}
Shown below:
GTK + Environment Setup (detailed) "Name=" image_operate_94091347012016076 "alt=" Windows GTK + Environment (detailed) "Src=" http://s13.sinaimg.cn/middle/ a6fb6cc9tc919a426653c&690 "real_src=" http://s13.sinaimg.cn/middle/a6fb6cc9tc919a426653c&690 ">
In this way, our GTK + Windows environment is set up, Hello World has been written successfully, hehe, the shortcomings have yet to be improved, I hope to have the opportunity to have a better study of GTK + and QT!
Note:Technology lies in communication, communication, reproduced please specify the source and maintain the integrity of the work.
╰☆ struggle ing? Child ' original: http://blog.sina.com.cn/s/blog_a6fb6cc901017ygy.html.
Windows GTK + Environment Setup (detailed)