Pkg config linux install

How To Install pkg-config on Ubuntu 22.04

In this tutorial we learn how to install pkg-config on Ubuntu 22.04.

What is pkg-config

pkg-config is a system for managing library compile and link flags that works with automake and autoconf.

Increasingly libraries ship with “.pc” files that allow querying of the compiler and linker flags needed to use them through the pkg-config(1) program.

There are three ways to install pkg-config on Ubuntu 22.04. We can use apt-get , apt and aptitude . In the following sections we will describe each method. You can choose one of them.

Install pkg-config Using apt-get

Update apt database with apt-get using the following command.

After updating apt database, We can install pkg-config using apt-get by running the following command:

sudo apt-get -y install pkg-config 

Install pkg-config Using apt

Update apt database with apt using the following command.

After updating apt database, We can install pkg-config using apt by running the following command:

sudo apt -y install pkg-config 

Install pkg-config Using aptitude

If you want to follow this method, you might need to install aptitude first since aptitude is usually not installed by default on Ubuntu. Update apt database with aptitude using the following command.

After updating apt database, We can install pkg-config using aptitude by running the following command:

sudo aptitude -y install pkg-config 

How To Uninstall pkg-config on Ubuntu 22.04

To uninstall only the pkg-config package we can use the following command:

sudo apt-get remove pkg-config 

Uninstall pkg-config And Its Dependencies

To uninstall pkg-config and its dependencies that are no longer needed by Ubuntu 22.04, we can use the command below:

sudo apt-get -y autoremove pkg-config 

Remove pkg-config Configurations and Data

To remove pkg-config configuration and data from Ubuntu 22.04 we can use the following command:

sudo apt-get -y purge pkg-config 

Remove pkg-config configuration, data, and all of its dependencies

We can use the following command to remove pkg-config configurations, data and all of its dependencies, we can use the following command:

sudo apt-get -y autoremove --purge pkg-config 

References

Summary

In this tutorial we learn how to install pkg-config package on Ubuntu 22.04 using different package management tools: apt, apt-get and aptitude.

Читайте также:  Generate pgp key linux

Источник

Understanding the pkg-config Linux Command

“The pkg-config is a handy tool for compiling libraries and applications, especially for developers. It acts as a helper to ensure the correct compiler options get inserted on the command line with ease instead of hard-coding values, such as where to locate different libraries.

The pkg-config is free software that supports different platforms, including Unix-like systems, Windows, Linux, and Mac OS X. To use pkg-config, you only need glib installed or a working C library and compiler. Let’s look at the common usage and understand pkg-config more in the sections below.”

Installing pkg-config

You can install pkg-config from the apt database:

First, update the apt database.

Next, install pkg-config.

pkg-config Description

pkg-config is a helper tool that mainly collects the metadata about installed libraries on computer systems and provides them to a user for easy assembling and integration. Each system has different libraries installed and to compile and link the libraries requires using pkg-config.

Furthermore, installing pkg-config alongside different packages makes it easy to adopt APIs in the case of developers. To be precise, pkg-config works by providing details necessary to compile and link programs to different libraries. Therefore, it fetches the metadata about the libraries instead of your hard coding on the terminal.

pkg-config Usage Examples

The metadata files that pkg-config retrieves information from have a .pc extension, and the name specified in the command is the metadata file.

The –libs option is specified to display the link flags associated with a given package. In our example, we will use the OpenCV C++ library.

The displayed output link flags are:

2. Print Compile Flags

The –cflags prints the compile flags and the associated pre-processor required to compile a package plus the flags for its dependencies.

Читайте также:  Команда dev в linux

3. Get a Version of the Library

You can check the version of a library using the —modversion flag.

4. Print Errors

You can print an error message, such as a missing dependency or modules, using the command:

To print errors in the stdout instead of the default stderr, use the —errors-to-stdout option instead of the —print-errors.

5. Display Variables in a Package

To see all the variables included in a given package, use the —print-variables option:

It will output all the names of any variable contained in your package.

6. List Packages

To show all the packages that have a .pc extension on your system, use the –list-all option

The output contains all packages listed in the PKG_CONFIG_PATH variable path.

7. Get Variable Value

You can get the value of a variable declared in a package’s .pc file. Use the —variable=[variable-name] [name-of-package] as in the example below.

8. Define Variable

You can set a global variable value for a .pc file with pkg-config. For instance, to declare a variable named prefix in our OpenCV library, we can use the command:

9. Other Options

–help: it opens the help message for the pkg-config.

–debug: it shows the debug information.

–static: it displays libraries with static linking, including private libraries.

Format of pkg-config Files

If you have a module, in our case named sample, the module will have a .pc file that contains its metadata.

There is a specific format used with the modules. Furthermore, a module has particular keywords, including:

Name: it represents the name of the given library or package. In our case, it is a sample.

Description: it represents a description of the library or package.

Version: libraries have different versions, and the version is specified using this keyword.

URL: the URL links to an external place to download the library or get more details about its usage.

Requires: if the package requires other packages, they get specified here.

Libs: the link flags for the package

Cflags: the compiler flags associated with the package.

Conflicts: it highlights any packages that are likely to conflict with it.

Requires.private represents the required private packages not available to other applications.

Conclusion

The pkg-config Linux command offers many usage cases, and you can get more details about the tool from its manpage. We’ve covered most of its common usage cases to help you comfortably extract details of libraries and packages. That’s it, folks!

Читайте также:  Green linux 21 rus

About the author

Denis Kariuki

Denis is a Computer Scientist with a passion for Networking and Cyber Security. I love the terminal, and using Linux is a hobby. I am passionate about sharing tips and ideas about Linux and computing.

Источник

How To Install pkg-config on Kali Linux

In this tutorial we learn how to install pkg-config on Kali Linux.

What is pkg-config

pkg-config is a system for managing library compile and link flags that works with automake and autoconf.

Increasingly libraries ship with “.pc” files that allow querying of the compiler and linker flags needed to use them through the pkg-config(1) program.

There are three ways to install pkg-config on Kali Linux . We can use apt-get , apt and aptitude . In the following sections we will describe each method. You can choose one of them.

Install pkg-config Using apt-get

Update apt database with apt-get using the following command.

After updating apt database, We can install pkg-config using apt-get by running the following command:

sudo apt-get -y install pkg-config 

Install pkg-config Using apt

Update apt database with apt using the following command.

After updating apt database, We can install pkg-config using apt by running the following command:

sudo apt -y install pkg-config 

Install pkg-config Using aptitude

If you want to follow this method, you might need to install aptitude first since aptitude is usually not installed by default on Kali Linux. Update apt database with aptitude using the following command.

After updating apt database, We can install pkg-config using aptitude by running the following command:

sudo aptitude -y install pkg-config 

How To Uninstall pkg-config on Kali Linux

To uninstall only the pkg-config package we can use the following command:

sudo apt-get remove pkg-config 

Uninstall pkg-config And Its Dependencies

To uninstall pkg-config and its dependencies that are no longer needed by Kali Linux, we can use the command below:

sudo apt-get -y autoremove pkg-config 

Remove pkg-config Configurations and Data

To remove pkg-config configuration and data from Kali Linux we can use the following command:

sudo apt-get -y purge pkg-config 

Remove pkg-config configuration, data, and all of its dependencies

We can use the following command to remove pkg-config configurations, data and all of its dependencies, we can use the following command:

sudo apt-get -y autoremove --purge pkg-config 

References

Summary

In this tutorial we learn how to install pkg-config using different package management tools like apt, apt-get and aptitude.

Источник

Оцените статью
Adblock
detector