在linux环境下添加头文件搜索路径

在编译rdma-core的时候,发现这个工程有个奇葩的事情,它不像普通的开源软件,使用configure --prefix= /make/make install 就可以完成安装了,看他的readme文件,也是没有涉及相关的命令。
但它有个简单的编译脚本build.sh,可以直接编译出对应的二进制。
在运行build.sh命令之后,在build目录下,会生成对应的build/bin, build/lib, build/include等文件夹,可以直接运行./ibv_devices,可以直接查看当前系统的ib设备状态;

ubuntu@ubuntu:~/work/rdma-core/build/bin$ ./ibv_devices 
    device          	   node GUID
    ------          	----------------
    mlx5_0          	0000000000000000
    mlx5_1          	0000000000000001
    hns_0           	04de13fffe25780b
    hns_1           	020610fffe55d2d9
    hns_2           	02182dfffe080047
ubuntu@ubuntu:~/work/rdma-core/build/bin$ 

说明工具可以使用,但build.sh不支持安装工具,没有办法安装到系统,所以需要把build目录添加到系统的路径;

export PATH=/home/ubuntu/work/rdma-core/build/bin:$PATH
export LD_LIBRARY_PATH=/home/ubuntu/work/rdma-core/build/lib

这个就可以直接运行ibv_devices命令了。
但我们在编译perftest时候,出现了如下错误:

checking for ANSI C header files... (cached) yes
checking infiniband/verbs.h usability... no
checking infiniband/verbs.h presence... no
checking for infiniband/verbs.h... no
configure: error: ibverbs header files not found

找不到添加文件,那有2种方法,第一种是apt install ibibverbs-devel, 第二种是将上述编译的头文件添加到系统路径;
因为我们希望使用最新的版本,所以采用第二种方法;

export C_INCLUDE_PATH=/home/ubuntu/work/rdma-core/build/include:$C_INCLUDE_PATH
export LIBRARY_PATH=/home/ubuntu/work/rdma-core/build/lib:$LIBRARY_PATH

问题解决;

posted @ 2022-09-17 11:11  cn风  阅读(1559)  评论(0)    收藏  举报