GTK + learning: build an environment

Source: Internet
Author: User

After learning about GTK +, the following describes how to build an environment for GTK + learning. The environment must be set up on two platforms: Windows and Linux: on the [url] http://www.gtk.org/download.html [/Url] You can find the Windows (32-bit) and 64-bit versions to download. Select the corresponding version based on whether your system is 32-bit or 64-bit, GTK + individual packages on the page are required for GTK + running, and Third Party Dependencies is a Third-Party dependent library. In this way, we can download the corresponding library files as needed to minimize the number of GTK + libraries. For simplicity, a bundle package is also provided on the page, which packages all the libraries and can be downloaded for use. Note that the bundle package is not listed separately, but the link provided in the page body. You may need to look for it carefully. Here we download the bundle package. After decompression, we can add the bin folder in it to the environment variable path so that we can find the dll when compiling the exe file. Otherwise, copy these dll files to the same directory as the exe file. You can also copy all the dll files in the bin to the C: \ WINDOWS \ system32 folder, because even if you add these dll files to the system environment variables, you cannot find the dll for running in the IDE, copy to the system32 folder. The following uses VC6 to configure the compiling environment. First, select Include files under the Tools-Options directory of VC6, add the include folder under the GTK + directory and all the first-level subdirectories in it, and then add the include folder in the subdirectory under the lib folder, in this case, 10 directories are added: 650) this. width = 650; "onclick = 'window. open (" http://blog.51cto.com/viewpic.php?refimg= "+ This. src) 'alt =" "src =" http://www.bkjia.com/uploads/allimg/131228/1ZS2M33-0.png "Border =" 0 "/> then add the lib folder under the GTK + directory in Library files: 650) this. width = 650;" onclick = 'window. open (" http://blog.51cto.com/viewpic.php?refimg= "+ This. src) 'alt =" "src =" http://www.bkjia.com/uploads/allimg/131228/1ZS24551-1.png "Border =" 0 "/> in this way, VC6 is configured, and VS2008 is similar. Create a console Project (VC6) or an empty project (VS2008), open the settings of the project, and clear the original Object/library modules in the link tab, then add glib-2.0.lib gtk-win32-2.0.lib gdk-win32-2.0.lib gobject-2.0.lib gdk_pixbuf-2.0.lib gthread-2.0.lib gmodule-2.0.lib intl. lib, OK. VC6 and VS2008 are used here. After this setting, you can create a new main. c file, and enter: # include <gtk/gtk. h> int main (int argc, char ** argv) {GtkWidget * window;
Gtk_init (& argc, & argv );
Window = gtk_window_new (GTK_WINDOW_TOPLEVEL );
G_signal_connect (GTK_OBJECT (window), "destroy", G_CALLBACK (gtk_main_quit), NULL );
Gtk_widget_show (window );
Gtk_main ();
Return 0;} compile, Link, run, window appears, indicating successful environment configuration: 650) this. width = 650; "onclick = 'window. open (" http://blog.51cto.com/viewpic.php? Refimg = "+ this. src) 'alt = "" src = "http://www.bkjia.com/uploads/allimg/131228/1ZS24C8-2.png" border = "0"/> Linux platform: first declare that I use Ubuntu for Linux and gnome for desktop. As mentioned earlier, gnome is written using GTK +. Therefore, the runtime environment does not need to be configured separately. The environment required for installation and development is required. The installed Ubuntu has installed gcc by default, but does not install the required header file. We need to manually add: sudo apt-get install build-essential and then install gnome: the sudo apt-get install gnome-core-devel System Automatically finds the dependent libraries and downloads them together. After installation, use the following command to compile the above Code: gcc main. c-o main 'pkg-config -- cflags -- libs gtk +-2.0 Note: 'Here is the back quotation marks on the left side of the keyboard, not single quotation marks. It is unclear how to configure GTK + on the KDE Desktop. The steps may be similar, but do you need to install the running environment of GTK + first? The above is the GTK + Environment configuration on Windows and Linux platforms. These steps have passed the test on my machine. After the environment is configured, we will start to learn new things.

This article is from the "bean space" blog, please be sure to keep this source http://devbean.blog.51cto.com/448512/108092

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.