Compile the GTK2.0 Program

Source: Internet
Author: User
Compile the GTK2.0 Program-general Linux technology-Linux programming and kernel information. The following is a detailed description. GTK is the c/c ++ language graphics library used to develop 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.

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.