Build a GTK + development environment in Windows XP (modified successfully)

Source: Internet
Author: User
Tags gtk

 

With the method of the original author, it is okay to compile and run only one source code, but an error will be reported during the connection phase when multiple source codes are compiled and run according to the engineering situation. after debugging for multiple times, I found that the problem was reversed when I added the compilation connection parameters.

 

1.The first step is to use two important software: dev-cpp4.9.9.2and gtk-dev-2.12.9-win32-2.exe. The former is a free C/C ++ ide under Windows XP, using the mingw compiler; the latter is the library and configuration program required for GTK + development.

2. After the download is complete, of course the installation is complete. We first install the Dev-Cpp4.9.9.2, installation according to the default can be (the default installation in C:/dev-CPP) after the installation is complete, start the software, and then follow the prompts to operate, the following page is displayed:

Install gtk-dev-2.12.9-win32-2.exe. you can install gtk-dev-2.12.9-win32-2.exe only by following the instructions in the installation process. Note that you can select Dev-CPP when selecting IDE.

3. After installing the above two programs, restart Dev-CPP and follow the prompts. In this case, the environment variables and Dev-CPP directory settings should have been set. But let's confirm:

(1) environment variables: Right-click "my computer"> "properties"> "advanced"> "environment variables"> "system variables ", "% gtk_basepath %/bin" is added to the path ",

(2) Dev-CPP directory settings: "Tools" --> "compiler options" --> "directory"

① --> "Database ":

.../GTK/lib

② --> "C contains files ":

.../GTK/include

.../GTK/include/gtk-2.0

../GTK/include/glib-2.0

.../GTK/include/pango-1.0

.../GTK/include/Cairo

.../GTK/include/atk-1.0

.../GTK/include/gtkglext-1.0

.../GTK/include/libglade-2.0

.../GTK/include/libxml2

.../GTK/lib/gtk-2.0/include

.../GTK/lib/glib-2.0/include

.../GTK/lib/gtkglext-1.0/include

"…" The path is determined based on your installation path. If both programs are installed in the default path, they should be the same as those shown above. In this case, the development environment of GTK + in Windows XP has been set up!

4. here we need to add something. Start Dev-CPP, "file" -- à "new" -- à "source code", and then write the following simple program into the editing area:

# Include <GTK/GTK. h>

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), "Hello World ");
Gtk_widget_show (window );
Gtk_main ();

Return 0;
}

Before compilation, we need to do something, "tool" -- à "compiler options" -- à "compiler", and then:

 

Note: (1), (2) the parameters are reversed.

 

(1) Check "Add the following command (Add the following commands when calling compiler) during compilation", and enter the following content in the edit box:

-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

(2) Check "Add the following command (addd these commands in the linker command line) in the connector command line" and add the following content to the edit box:

-MMS-bitfields

After confirming, compile the code and run the program. If no error occurs, we can see the following window:

So far, this tutorial is complete. As to why the above content is added, how to use Dev-CPP is not within the scope of this tutorial. I will not answer these questions in detail here. If you are interested, please google it!

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.