Install Ubuntu GTK

Source: Internet
Author: User
Tags gtk
Install GTK

Sudo apt-Get install Vim # Use Vim to write code. Of course, you can use any editor you like.

Sudo apt-Get install build-essential # This will install basic programming tools such as gcc/g ++/GDB/make

Sudo apt-Get install gnome-core-devel # This will install libgtk2.0-dev libglib2.0-Dev and other development-related library files

Sudo apt-Get install PKG-config # used to automatically find the header file and library file location when compiling the GTK Program

Sudo apt-Get install devhelp # This will install the devhelp GTK document viewing program

Sudo apt-Get install libglib2.0-Doc libgtk2.0-doc # This will install the GTK/glib api reference manual and other help documents

Sudo apt-Get instal Glade libglade2-dev # This will install GTK-based interface GTK is the C/C ++ language graphics library for developing gnome windows. I had a hard time on the Ubuntu machine and copied the online tutorial code to compile it on the local machine. Code File Name: t1.c. Follow the tutorial to compile with the following command:

GCC t1.c 'pkg-config -- cflags -- libs GTK +-2.0'

Compilation result: GTK/GTK. H is not found.

Because my Ubuntu is a gnome system, I thought that GTK + 2.0 development programs (header files and library files) should have been installed on the computer. Otherwise, if you develop a GTK + 2.0 program on Ubuntu, you need to install the corresponding header file and library. In the console window, enter sudo apt-Get install libgtk2.0 *. All files required for GTK + 2.0 are downloaded and installed. Apply the compilation command again: GCC t1.c 'pkg-config -- cflags -- libs GTK +-2.0, compile and run.

PKG-config is a program used to manage packages. On the console, enter the running result of PKG-config -- cflags -- libs GTK +-2.0:

-Dpng_no_mmx_code-I/usr/include/gtk-2.0-I/usr/lib/gtk-2.0/include-I/usr/include/atk-1.0-I/usr/include/Cairo-I/usr /include/pango-1.0-I/usr/include/glib-2.0-I/usr/lib/glib-2.0/include-I/usr/include/FreeType2-I/usr/include /libpng12-lgtk-x11-2.0-lgdk-x11-2.0-latk-1.0-lgdk_pixbuf-2.0-lm-lpangocairo-1.0-lfontconfig-lxext-lxrender-lxinerama-LXI-lxrandroid-lxcursor-lxcomposite-lxdamage-lpango-1.0-lcairo-lx11-lxfixes -lgobject-2.0-lgmodule-2.0-LDL-lglib-2.0

It can be seen that the output text includes all the options required for GCC to compile GTK + 2.0 (header file directory and library file ).

Note that the GCC t1.c 'pkg-config -- cflags -- libs GTK +-2.0 ', the quotation marks on both sides of PKG-config -- cflags -- libs GTK +-2.0 are not real quotation marks, but the character on the leftmost side of the keyboard number. If a single quotation mark is used incorrectly, GCC cannot use the text generated by PKG-config -- cflags -- libs GTK +-2.0 as the compilation option. Constructor.
$ GCC gtkhello. C-o gtktest 'pkg-config -- cflags -- libs GTK +-1000'
$./Gtktest
GCC gtk1.c 'pkg-config -- cflags -- libs GTK +-2.0'

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.