编译环境:Linuxmint21
e2fsprogs版本:1.42.8
问题复现:
-
去sourceforge下载e2fsprogs的源码,然后在Linuxmint21系统下解压;
-
解压出源码后,在该e2fsprogs库的根目录下执行
./configure --enable-elf-shlibs
(该后面这一参数是用来编译动态库的),最后会生成makefile文件 -
执行
make -j4
开始编译该库,然后出现如下报错:/usr/bin/ld: …/lib/libblkid.so: undefined reference to `makedev’
collect2: error: ld returned 1 exit status
make[2]: *** [Makefile:391:e2fsck] 错误 1
解决方法:
进入e2fsprogs的项目根目录,然后修改./lib/blkid
路径下的devname.c
源码:在头部包含头文件的位置添加一句#include <sys/sysmacros.h>
(如下面代码第30行),然后在e2fsprogs项目根目录重新执行make -4
编译即可
#define _GNU_SOURCE 1
#include "config.h"
#include <stdio.h>
#include <string.h>
#include <limits.h>
#if HAVE_UNISTD_H
#include <unistd.h>
#endif
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#if HAVE_SYS_TYPES_H
#include <sys/types.h>
#endif
#include <dirent.h>
#if HAVE_SYS_STAT_H
#include <sys/stat.h>
#endif
#if HAVE_ERRNO_H
#include <errno.h>
#endif
#if HAVE_SYS_MKDEV_H
#include <sys/mkdev.h>
#endif
#include <time.h>
#include "blkidP.h"
#include <sys/sysmacros.h> //这是我新加的