Linux 编译libsmtp时出错(找不到glib配置)

Linux 编译libsmtp时出错(找不到glib配置),linux,ubuntu-12.04,smtplib,Linux,Ubuntu 12.04,Smtplib,我试图在Ubuntu 12.04上安装,编译时出现错误,下面是我遵循的步骤(它们与在install.txt文件中编写的完全相同) [上述命令的输出为] 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 check

我试图在Ubuntu 12.04上安装,编译时出现错误,下面是我遵循的步骤(它们与在install.txt文件中编写的完全相同)

[上述命令的输出为]

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
这个列表还在继续,但仍安装了其余的依赖项。 从输出中可以看出,它无法找到“lglib”,但它实际已安装,modversion的输出为:

usama@ubuntu:~/Desktop/smtp/libsmtp-0.8.5$ pkg-config --modversion glib-2.0
2.32.3
由于这个原因,我在运行“make”时出错,下面是输出:

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
谁能告诉我如何解决这个问题

更新:

configure脚本中处理glib的部分是:

 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

最后,我能够摆脱油嘴滑舌的错误,以下是您需要遵循的步骤:

首先确保您的系统上已安装libgtk2.0,如果未安装libgtk2.0,则可以使用以下命令进行安装:

sudo apt-get install libgtk2.0-dev 
pkg-config --cflags glib-2.0
告诉编译器glib-2.0的路径,确切的命令写在下面: (注意:libgtk的路径在您的系统中可能不同,要检查路径,请使用以下命令:)

U应获得与以下类似的输出:

-I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include 
现在安装libsmtp(或所需的应用程序)


如果你幸运的话,你就可以安装你想要的应用程序。

Glib真奇怪!你必须告诉编译器使用Glib自己的include路径(应该在/usr/include/Glib-2.0或类似的文件中)。嗯,我该怎么做呢?[如果你能告诉我确切的命令?]是的,在/usr/include/glib-2.0../configure[…等…]CFLAGS='-I/usr/include/glib-2.0'CPPFLAGS='-I/usr/include/glib-2.0'在编写这个命令'pkg-config--CFLAGS--libs-glib-2.0'时,我得到了这个输出:'-I/usr/include/glib-2.0--I/usr/lib/x86_64-linux-gnu/glib-2.0/include-lglib-2.0'我给了CFLAGS和CPPFLAGS进行如下配置:,./configure CFLAGS='-I/usr/include/glib-2.0'CPPFLAGS='-I/usr/lib/x86_64-linux-gnu/glib-2.0/include',但仍然无法找到glib://这可能是因为libsmtp的配置脚本也很奇怪:它有
glib-config
硬编码。您可以将该
pkg config…
放入名为
glib config
的脚本中,使其可从路径访问,然后重试
cd libsmtp
./configure
make CFLAGS='-I/usr/include/glib-2.0' CPPFLAGS='-I/usr/lib/x86_64-linux-gnu/glib-2.0/include'
sudo apt-get install libglib2.0-dev
cd libsmtp
./configure
make CFLAGS='-I/usr/include/glib-2.0' CPPFLAGS='-I/usr/lib/x86_64-linux-gnu/glib-2.0/include'
sudo apt-get install libglib2.0-dev