---
title: Lmbench.stream测试工具编译失败的解决方法
description: "环境配置："
url: https://www.hikunpeng.com/document/detail/zh/kunpenggrf/trouble/kunpenggeneral_troublecase_043.html
sourcePath: /source/zh/kunpenggrf/trouble/kunpenggeneral_troublecase_043.html
indexId: 4be8eab880d097d4bb448cb484b536a1734d1bdcefe97cbac2f6f9dd4efe1a4465
---
# Lmbench.stream测试工具编译失败的解决方法

#### 问题现象描述

环境配置：

| 硬件配置 | 鲲鹏服务器（鲲鹏916处理器，8\*32G，DDR4 2400MHz） |
| --- | --- |
| 测试工具 | Lmbench.stream测试工具 |
| 操作系统与软件 | CentOS 7.6，GCC 7.3.0，glibc 2.2.8 |


问题描述：

Lmbench.stream软件解压后，编译失败，提示：

```
/tmp/ccid4aB6.o：在函数‘seekto’中：disk.c:(.text+0x44)：对‘llseek’未定义的引用
/tmp/ccid4aB6.o：在函数‘seekto’中：disk.c:(.text+0x44)：对‘llseek’未定义的引用
collect2: 错误：ld 返回 1
gmake[2]: *** [../bin//disk] Error 1
gmake[2]: Leaving directory   `/home/username/lmbench3/src'
make[1]: *** [lmbench] Error 2
make[1]: Leaving directory   `/home/username/lmbench3/src'
make: *** [build] Error 2
```


#### 关键过程、根本原因分析

分析过程：

1. 首先从提示信息已经很明确的反应出问题的发生点即在disk.c文件中seekto函数中llseek参数未定义就引用。
2. 在本地搜索出该源代码的位置./src/disk.c，打开源码文件并搜索出llseek的位置。

```
seekto(int fd, uint64 off)
{
#ifdef  __linux__
extern  loff_t llseek(int, loff_t, int);
if (llseek(fd, (loff_t)off, SEEK_SET) == (loff_t)-1) {
return(-1);
}
return (0);
#else
uint64  here = 0;
lseek(fd, 0, 0);
while ((uint64)(off - here) > (uint64)BIGSEEK) {
if (lseek(fd, BIGSEEK, SEEK_CUR) == -1) break;
here += BIGSEEK;
}
assert((uint64)(off - here) <= (uint64)BIGSEEK);
if (lseek(fd, (int)(off - here), SEEK_CUR) == -1) return (-1);
return (0);
#endif
```


3. 将问题代码拷贝出来，简单写一个main函数单独编译。

```
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include <sys/types.h>
#include <unistd.h>
#include <stdlib.h>
int main(int argc, char **argv)
{
int fd = 0;
int off = 0;
#if 1
if (llseek(fd, (loff_t)off, SEEK_SET) == (loff_t)-1) {
return(-1);
}
return 0;
#endif
}
```


根本原因分析：大数据重新定位读/写文件偏移量时，llseek接口函数在GCC 7.3.0编译器中被lseek64替代。


#### 结论、解决方案及效果

将测试工具的disk.c源码文件中的llseek接口函数全部替换成lseek64，重新编译。
