Dev-CPP/mingw32 Environment Introduction (11)

Source: Internet
Author: User
Tags gtk

Dev-CPP/mingw32 Environment Introduction (11)

Review above:

In the previous article, I introduced you to the installation and Setup of SDL. I hope you will be able to benefit from this, as stated last time. This time we will install the GTK runtime and Development Library. Of course, this is all done under Win32. I hope you will fall in love with this.

Chapter 4 download and install GTK

GTK? Many may wonder why GTK is required when MFC is available? In fact, MFC is not a cross-platform GUI. GTK can run on multiple platforms. Such as Linux and Mac. Of course, it also includes Win32. If you want your program to be compiled in one place and compiled in multiple places. GTK is a very good GUI.
GTK has already introduced how to install it through the installer. However, you may not be able to install those newer libraries. In addition, it is not free enough. Next, I will introduce how to download and install the Win32 version of GTK from the GTK official website. I don't want to introduce GTK.

GTK's official website http://www.gtk.org found Win32. On the download page of this website, you will find many download links. These are part of GTK. You can download the corresponding data files as needed. However, you must download the following files, which is required.

Glib
Libiconv
Gettext-runtime
GTK +
ATK
Pango

If you just run it, you only need to download the runtime. If you want to develop it, you also need to download the data file with Dev (note that there is also a source file ). At the time of writing this article, the latest and stable GTK version is 2.6.

After the download is complete, we only need to compress it to a directory. However, note that Dev and runtime must be compressed to two directories separately to avoid confusion.
In

/Include/gtk-2.0
/Lib/gtk-2.0/include
/Include/atk-1.0
/Include/pango-1.0
/Include/glib-2.0
/Lib/glib-2.0/include

Add as header file path

/Lib

Add as library file path

Add the following parameters when linking
-Lgtk-win32-2.0-lgdk-win32-2.0-latk-1.0-lgdk_pixbuf-2.0-lpangowin32-1.0-lgdi32-lpango-1.0-lgobject-2.0-lgmodule-2.0-lglib-2.0-lintl-liconv
Add the following parameters during compilation
-MMS-bitfields

In this way, the installation of our GTK Development Library is complete.

However, if you run the task, you have to configure the system.

Add the path of the bin folder and Lib folder to the system PATH variable. Alternatively, you can copy the files in the Lib folder to the bin folder and add the bin path as a system variable. (The latter is recommended on the official website ).

So far, our GTK development environment and runtime environment have been set up. The following provides a simple set of makefile and example code.

#Makefile.txt
Cc = gcc
Gtk_path =
Cflags =-MMS-bitfields-I "$ (gtk_path)/include/gtk-2.0"-I "$ (gtk_path)/lib/gtk-2.0/include"-I "$ (gtk_path) /include/atk-1.0 "-I" $(gtk_path)/include/pango-1.0 "-I" $(gtk_path)/include/glib-2.0 "-I" $ (gtk_path) /lib/glib-2.0/include"

Lflags =-L "$ (gtk_path)/lib" lgtk-win32-2.0-lgdk-win32-2.0-latk-1.0-lgdk_pixbuf-2.0-lpangowin32-1.0-lgdi32-lpango-1.0-lgobject-2.0-lgmodule-2.0-lglib-2.0-lintl-liconv

ALL:
$ (CC) $ (cflags)-c gtk. C-o GTK. o
$ (CC) $ (lflags)-O gtk.exe GTK. o

#Makefile.txt end

// GTK. c

# Include <GTK/GTK. h>
Static void destroy (gtkwidget * widget, gpointer data)
{
Gtk_main_quit ();
}
Int main (INT argc, char * argv [])
{
Gtkwidget * window;
Gtk_init (& argc, & argv );
Window = gtk_window_new (gtk_window_toplevel );
Gtk_window_set_title (gtk_window (window), "GTK + programe ");
G_signal_connect (g_object (window), "Destroy ",
G_callback (destroy), null );
Gtk_widget_show (window );
Gtk_main ();
Return 0;
}

// GTK. C end

So far, the configuration and installation of GTK have been completed here. The preceding settings are described in detail. Therefore, we will not explain it in depth here. If you do not understand, you can submit it here or look for the previous content. Since many articles in this series are reproduced, If you view them on the reposted website. You can find the latest article on http://blog.csdn.net/visioncat. At the same time, you can also put forward your questions and suggestions in the above article for the most direct help.

VOICEOVER:
After this article, mingw/dev-C ++ will be introduced in the intermediate article. The original descriptions of settings and operations for Dev-CPP will be basically stopped (as described only when necessary ). In turn, we will give a more detailed introduction to mingw and other GCC Win32 compilers for your in-depth use. I don't think you always want to stay in an IDE and use Dev-CPP. In fact, the core compiler in Dev-CPP is mingw. Therefore, the content you read in intermediate articles can also be applied to Dev-CPP. You can modify Dev-CPP to use intermediate content. However, I will focus on makefile. As shown in chapter 16 of Chapter 15th. However, the content will be richer. Coming soon.

Studio software development group (SDT)
Studio development team
Dipper (Huang yaokui)

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.