So, do you know how to compile?

In this way?

./configure
make
sudo make install

But that’s not true, first you have to install the dependences which usually are listed in the README file, so it’s a four steps formula.

Many people haven’t told you, but ./configure will tell you if you can continue or not, if ./configure complains, you cannot continue with the compilation, sometimes it can help you to disable support to some features, you can disable support to some features reading the available parameters with ./configure --help, then you can run ./configure --disable-ssl by example.

So you are ready, you installed the dependences, but suppose that you had errors in ./configure.

This time ./configure is complaining that a library or package is missing, but that is wrong since you are pretty sure you installed it. I have had this error a lot when I try to compile in Slackware due that my root shell is not loading the environment variables. For that you have to create a this file: /root/.bashrc and add:

source /etc/profile

Then execute the same line that you added:

source /etc/profile

Maybe the environment variables are loaded and still the problem persist, so let’s check the most important environment variabe related to the compilation, PKG_CONFIG_PATH:

echo $PKG_CONFIG_PATH

It has to print a list of paths separated by a colon like this:

/usr/local/lib64/pkgconfig:/usr/local/share/pkgconfig:/usr/lib64/pkgconfig:/usr/share/pkgconfig

You must know that pkgconfig is a folder that contains the linking information of libraries in many files, and so pkg-config is a command line tool, so instead of pointing the location of the headers libraries as in the following line of code:
gcc -o test test.c -I/usr/include/glib-2.0 -I/usr/lib64/glib-2.0/include -lglib-2.0

We only specify the library name (glib-2.0) with the pkg-config code:

gcc -o test test.c $(pkg-config --libs --cflags glib-2.0)

Of course it’s done automatically in ./configure, make and make install formula.

Please notice the command between the parenthesis:

pkg-config --libs --cflags glib-2.0

It will return something like this:

-I/usr/include/glib-2.0 -I/usr/lib64/glib-2.0/include -lglib-2.0

You can try it by yourself

This is posible because the pkg-config reads the /usr/lib64/pkgconfig/glib-2.0.pc file that contains that information, notice that it has a .pc extension; so, tell me, how pkg-config know about this file? Thanks to the aforementioned PKG_CONFIG_PATH environment variable , check in the PKG_CONFIG_PATH variable if /usr/lib64/pkgconfig is included, and of course it is. So the file name is the same as the library plus the .pc extension.

This is the contain of that file:

prefix=/usr
exec_prefix=${prefix}
libdir=/usr/lib64
includedir=${prefix}/include
glib_genmarshal=glib-genmarshal
gobject_query=gobject-query
glib_mkenums=glib-mkenums
Name: GLib
Description: C Utility Library
Version: 2.46.2
Requires.private:
Libs: -L${libdir} -lglib-2.0
Libs.private: -pthread
Cflags: -I${includedir}/glib-2.0 -I${libdir}/glib-2.0/include

Notice the lines that begins with Libs and Cflags, libs and cflags were the parameters that we passed to pkg-config in the command of above:
pkg-config --libs --cflags glib-2.0
That returned the following, so please notice how the following output is generated, some variables are declarated in the glib-2.0.pc file and then are sourced inside another one as in the Cflags line where the variable ${includedir} was previusly declarated.
-I/usr/include/glib-2.0 -I/usr/lib64/glib-2.0/include -lglib-2.0

The important part is that ./configure command will create a file called “Makefile” , there in Makefile you will find the pkg-config retrieved libs and cflags, it is also possible that the ./configure script is not working properly, so you will have to edit manually the Makefile.

For example, yesterday I had this error, when I executed the make command, make could not find my glib library!, it was complaining that glib.h was not found and everything related with glib… So I modified my Makefile and added it in a “EXTRA_CFLAGS” variable, the Makefile contain lots of variables, and there you can add a missing directory in a CFLAG variable, so in the line that started like:

-pthread -I/usr/include/pidgin -I/usr/include/gtk-2.0 -I/usr/lib64/gtk-2.0/include -I/usr/include/pango-1.0 -I/usr/include/atk-1.0 -I/usr/include/cairo
I added in any position:
-I/usr/include/glib-2.0

And it worked

Remember that you have to include both the headers (Cflags) and libs, in this case glib is a fundamental library that had not reason to fail. Please do not mess with the main CFLAG variable.

Now remember that the ./configure script sometimes will help you with unlocated libraries as well, you have to execute:
./configure --help, and there will tell you which variables you can use to manually indicate the headers and libraries location.

Example, yesterday ./configure told me that I had a missing PURPLE package, I executed ./configure --help and it told me that I can use the PURPLE_CFLAGS variable and the PURPLE_LIBS to manually indicate the location of the PURPLE package.

I solved it executing:

export PURPLE_CFLAGS='-I/usr/local/lib/include/libpurple'
export PURPLE_LIBS=/usr/local/include/libpurple/
And of course again:
./configure

The compilation may fail in the make phase and it’s mainly the case of the maintained packages which are those who haven’t received any update in 2 years. Else, it’s a bug.

These bottons respect your privacy