Configure GTK in eclipse

Source: Internet
Author: User
Tags cairo gtk

Use Eclipse for GTK + programming
Eclipse Overview
Eclipse is an excellent open-source IDE and has now developed into a 10 thousand development platform. It supports all mainstream programming languages and can be used in Windows and Linux.
Its main feature is to provide code prompts during the coding process, and timely Error Detection for virtual machine languages. It is a powerful tool for developing Java, Python, and Ruby, and a rare tool for Web development.
Eclipse can also be used to develop C/C ++ applications. You only need to install a CDT plug-in.
 
The following describes how to configure GTK + program development using Eclipse.
Tool Version
This article assumes that you have installed Eclipse and CDT plug-ins, and set up the GTK + Development Environment (for how to set up the GTK + development environment, see GTK + programming Introduction).
The following are my tools and versions for comparison:
OS: Windows XP
Eclipse: 3.7.0
GCC: 4.5.2 (MinGW)
GTK +: Limit .2 (glade3-3.6.7-with-GTK +)

Step 01
Open the doscommand line and execute the following three commands in sequence:
Pkg-config -- cflags gtk +-2.0> include.txt
Pkg-config -- libs gtk +-2.0> libs.txt
Two. txt files will be generated under your d-root directory. We will use them later.

Step 02
Start Eclipse and create a new C Project named GTK +)

Step 03
Right-click the newly created GTK + project and select Properties at the bottom of the pop-up options.

Step 04
Eclipse will pop up the settings window for this project, click C/C ++ General at the left, and then click Paths and Symbols

Step 05
Click gnu c under the des option bar on the right, and then click Add... on the right to Add the path of GTK +.
Note: The Add to all invocations option must be checked for each addition.
What about fill in path? Open the include.txt file generated in step 1, which contains all the paths we need. The specific paths are as follows (depending on your GTK + installation path)
C:/GTK/include/gtk-2.0
C:/GTK/lib/gtk-2.0/include
C:/GTK/include/atk-1.0
C:/GTK/include/cairo
C:/GTK/include/pango-1.0
C:/GTK/include/glib-2.0
C:/GTK/lib/glib-2.0/include
C:/GTK/include/libpng12
Okay. The file path is set. The link library path is set below.

Step 06
In the Paths and Symbols window, click Library Paths in the middle, and then click Add... on the rightmost side to Add the path of the Linked Library of GTK +.
The Add to all invocations option must also be checked during addition.
You should have guessed how to find the path information. No error. Open the libs.txt file generated in step 1 and add the following path information (only one)
C:/GTK/lib
In this step, only the link library path is specified, but no specific link library name is specified.

Step 07
In the Paths and Symbols window, click Libraries in the middle, and then click Add... on the rightmost side to Add the GTK + link library one by one.
Similarly, do not forget to check the "Add to all invocations" option during addition.
Open the libs.txt file generated in step 1 and add the following database names one by one
Gtk-win32-2.0
Gdk-win32-2.0
Atk-1.0
Gio-2.0
Gdk_pixbuf-2.0
Pangowin32-1.0
Gdi32
Pangocairo-1.0
Pango-1.0
Cairo
Gobject-2.0
Gmodule-2.0
G Lib-2.0
Intl
The settings come to an end here, and the compilation options are set below

Step 08
Click the left-side C/C ++ Build option, and then click Settings.

Step 09
Select the top Configuration item as Debug, and then select the following Tool Settings Option

Step 10
Select the gcc c Compiler on the left of the Tool Settings option bar and change the Command on the right to gcc-mms-bitfields.

Step 11
Select the top Configuration item as Release, repeat the settings in step 1, and click the bottom OK button to confirm and exit the settings.
Now, the configuration of the entire Eclipse GTK + development environment is complete.
Configuration Summary
The entire process seems complicated, but it is not complicated at all. Let's repeat the configuration steps in a simple way:
Run the pkg-config command to obtain the path information of GTK +.
Open the project settings window www.2cto.com
Add GTK +'s file path, link library path, and link library
Set GCC compilation options for different Debug and Release modes.
Postscript
We recommend that you use GCC + Make + Vim to develop GTK + applications (this is also my development method)
However, if you are familiar with IDE or are not familiar with command line, you can consider GCC + Eclipse
The following provides a general Makefile for compiling GTK + 2. x. For example, 3.x, replace gtk +-2.0 with gtk +-3.0.
GTK_FLAGS = $ (shell pkg-config -- cflags -- libs gtk +-2.0)
All:
Gcc-Wall-std = c99-o app *. c $ {GTK_FLAGS}
Note: Makefile copying from a Web page may fail to be executed normally, so you 'd better press it by yourself. all: the front blank of the line below is a Tab, not a space.

Span style = nbsp; Use


Author: csh159

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.