Search code examples
linuxubuntu-12.04smtplib

Error in compiling libsmtp (glib-config not found)


I am trying to install libsmtp on Ubuntu 12.04, and upon compiling i am getting errors, here's the step i followed (they are exactly the same as written in Install.txt file)

cd libsmtp
./configure

[The output of above command is]

checking whether make sets $(MAKE)... yes
checking for gcc... gcc
checking for C compiler default output file name... a.out
checking whether the C compiler works... yes
checking whether we are cross compiling... no
checking for suffix of executables... 
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc accepts -g... yes
checking for gcc option to accept ANSI C... none needed
checking for a BSD-compatible install... /usr/bin/install -c
checking for ranlib... ranlib
checking for main in -lglib... no
checking for main in -lglib... (cached) no
checking how to run the C preprocessor... gcc -E

The list goes on, but remaining dependencies are installed. From the output it can be seen that its not able to find 'lglib', but its actually installed, the output of modversion is:

usama@ubuntu:~/Desktop/smtp/libsmtp-0.8.5$ pkg-config --modversion glib-2.0
2.32.3

And due to this i got error on running 'make', here's the output:

usama@ubuntu:~/Desktop/smtp/libsmtp-0.8.5$ make
make[1]: Entering directory `/home/usama/Desktop/smtp/libsmtp-0.8.5/smtp'
gcc -I. -I../include `glib-config --cflags` -g -O2 -DUSE_MIME   -c -o    libsmtp_comm.o libsmtp_comm.c
/bin/sh: 1: glib-config: not found
libsmtp_comm.c:28:20: fatal error: glib.h: No such file or directory
compilation terminated.
make[1]: *** [libsmtp_comm.o] Error 1
make[1]: Leaving directory `/home/usama/Desktop/smtp/libsmtp-0.8.5/smtp'
make: *** [all] Error 1

Can anyone please tell how to resolve this issue ?

Updated:

The portion of configure script dealing with glib is :

 echo "$as_me:$LINENO: \$? = $ac_status" >&5
 (exit $ac_status); }; }; then
 ac_cv_lib_glib_main=yes
 else
 echo "$as_me: failed program was:" >&5
 sed 's/^/| /' conftest.$ac_ext >&5

 ac_cv_lib_glib_main=no
 fi
 rm -f conftest.err conftest.$ac_objext \
   conftest$ac_exeext conftest.$ac_ext
 LIBS=$ac_check_lib_save_LIBS
fi
echo "$as_me:$LINENO: result: $ac_cv_lib_glib_main" >&5
echo "${ECHO_T}$ac_cv_lib_glib_main" >&6
if test $ac_cv_lib_glib_main = yes; then
cat >>confdefs.h <<_ACEOF
#define HAVE_LIBGLIB 1
_ACEOF

LIBS="-lglib $LIBS"

echo "$as_me:$LINENO: checking for main in -lglib" >&5
echo $ECHO_N "checking for main in -lglib... $ECHO_C" >&6
if test "${ac_cv_lib_glib_main+set}" = set; then
echo $ECHO_N "(cached) $ECHO_C" >&6
else
 ac_check_lib_save_LIBS=$LIBS
LIBS="-lglib  $LIBS"

Solution

  • Finally i am able to get rid of glib error, here are the steps u need to follow:

    First make sure that libgtk2.0 is installed on your system, if its not installed then u can install it with the following command:

    sudo apt-get install libgtk2.0-dev 
    

    Tell the compiler the path of glib-2.0, the exact command is written below: ( Note: The path of libgtk may differ in your system, to check the path use the following command:)

    pkg-config --cflags glib-2.0
    

    U should get an output similar to that:

    -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include 
    

    Now install the libsmtp (or your desired application).

    cd libsmtp
    ./configure
    make CFLAGS='-I/usr/include/glib-2.0' CPPFLAGS='-I/usr/lib/x86_64-linux-gnu/glib-2.0/include'
    

    If you are lucky then u would be able to install your desired application.