Configure, pkg-config, and pkg_config_path in Linux

Source: Internet
Author: User


In Linux, configure, pkg-config, and pkg_config_path refer to these three terms. I believe that Linux users will not be unfamiliar with them. The importance is self-evident. Next I will summarize the relationship between them. Configure is generally a script. During execution, you can input necessary parameters to inform the configuration project. For general open-source software, after downloading the source code, the configure file will be found in the directory after decompression and executed. the/configure file will generate the Makefile file, and the configure script will detect the corresponding dependent environment through the pkg-config tool when checking the corresponding environment. Pkg-config is used to retrieve information about installed library files in the system. Its main functions are as follows: 1. Check the database version number. If the required library version does not meet the requirements, it prints an error message to avoid link to the library file of the wrong version.
2. Obtain the pre-compilation parameters, such as macro definition and header file location. 3. Obtain the link parameters, such as the location of the database and other dependent libraries, file names, and other connection parameters. 4. automatically add the settings of other dependent libraries. Because the pkg-config tool is used to obtain the library options, the same compilation and connection commands can be used regardless of the directory where the library is installed, bringing the unity of compilation and connection interfaces. However, using the pkg-config tool to extract library compilation and connection parameters has two basic prerequisites: 1. The Library itself must provide a corresponding one during installation. pc file, if no. pc file Software generally does not support the use of the pkg-config tool. Www.2cto.com 2, pkg-config must know where to find this. pc file pkg_config_path: The environment variable PKG_CONFIG_PATH is used to set. pkg-config searches the pc file path in the order of the set path until the specified path is found. pc file. In this way, the search path of the header file of the library is actually changed to the search path setting for the. pc file. The following describes the problem based on a specific situation: when many people compile the GTK program, gtk appears. the reason why the H file cannot be found is that the environment variable is not configured. The first thing we need to do is to find the corresponding one. pc file, enter pkg-config -- modversion gtk +-2.0 in the terminal, and the system prompts that xproto cannot be found. in the pc file, you need to put the directory containing the file in PKG_CONFIG_PATH and search for it. The file is under/usr/share/pkgconfig. Then we will change the environment variable: export PKG_CONFIG =/usr/local/bin/pkg-configexport PKG_CONFIG_PATH =/usr/share/pkgconfig:/usr/lib/pkgconfig. Now, everything is OK, when we compile the corresponding program, the input command is gcc Demo. c-o Demo 'pkg-config -- cflags -- libs -- gtk +-2.0 'author Yi falls to dusk

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.