BLESS的安装---一个问题recompile with -fPIC的解决

BLESS安装方法

首先新建一个目录

mkdir bless_c++
cd bless_c++

然后把源码克隆到本地

git clone https://github.com/thirtyeggs/bless.git

进入目录,执行编译

cd bless
make -j8

编译报错

mpicxx kmc/kmc_api/kmc_file.o kmc/kmc_api/kmer_api.o kmc/kmc_api/mmer.o murmurhash3/MurmurHash3.o check_inputs.o correct_errors.o count_solid_kmers.o main.o parse_args.o -o bless ./boost/lib/libboost_filesystem.a ./boost/lib/libboost_system.a ./boost/lib/libboost_iostreams.a ./zlib/install/lib/libz.a -fopenmp -std=c++11
/usr/bin/ld: ./boost/lib/libboost_filesystem.a(operations.o): relocation R_X86_64_32 against symbol `__pthread_key_create@@GLIBC_2.2.5' can not be used when making a PIE object; recompile with -fPIC
/usr/bin/ld: ./boost/lib/libboost_filesystem.a(path.o): relocation R_X86_64_32S against symbol `_ZNSs4_Rep20_S_empty_rep_storageE@@GLIBCXX_3.4' can not be used when making a PIE object; recompile with -fPIC
/usr/bin/ld: ./boost/lib/libboost_system.a(error_code.o): relocation R_X86_64_32 against `.rodata.str1.1' can not be used when making a PIE object; recompile with -fPIC
/usr/bin/ld: ./boost/lib/libboost_iostreams.a(mapped_file.o): relocation R_X86_64_32S against symbol `_ZNSs4_Rep20_S_empty_rep_storageE@@GLIBCXX_3.4' can not be used when making a PIE object; recompile with -fPIC
/usr/bin/ld: final link failed: Nonrepresentable section on output
collect2: error: ld returned 1 exit status
Makefile:10: recipe for target 'bless' failed
make: *** [bless] Error 1

进入Makefile文件查看问题

看样子是第十行有点问题

QQ图片20210926193431

他这里说是执行到这一行的时候报错,让我们研究一下这一行具体做了什么

了解过Makefile的同学都知道,这一行实际意思就是将LAFLAGS这些库链接为$(OBJ)也就是bless,应该是整个编译过程比较靠后的位置,使用的编译器为mpicxx,那么这个mpicxx又是何方神圣呢

不妨新开一个终端,在命令行输入一下这个命令

mpicxx --version                                                                       master ✗
g++ (Ubuntu 7.5.0-3ubuntu1~18.04) 7.5.0
Copyright (C) 2017 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

查阅资料发现,这个其实就是编译链接使用c++开发的MPI项目,没听说过是干什么的(暴露了知识的贫乏),不过似乎感觉类似于g++

Screenshot from 2021-09-26 21-52-00

官网这里给出了一些参数,输入--help查看一下比较详细的情况

里面有一个pie参数

  -pie                     Create a position independent executable.

立刻想到之前的报错信息

/usr/bin/ld: ./boost/lib/libboost_filesystem.a(operations.o): relocation R_X86_64_32 against symbol `__pthread_key_create@@GLIBC_2.2.5' can not be used when making a PIE object; recompile with -fPIC

查阅资料发现PIE(Position-Independent-Executable)是位置无关的程序,产生的每一条指令,全部使用相对地址,可以被加载到内存的任意位置,就像共享库一样。那么在这个问题中,又是怎么回事呢?

看起来是要加上参数-fPIC,但是仔细一看,却发现真正的原因其实是boost库的问题,也就是那些.a文件不匹配,这些文件既然不匹配,那么推测就不能使用-fPIC参数,所以需要在编译参数中加上-no-pie即可

2

加上后果然正常了,不过发现cd到下面的目录又是相同的错误

Screenshot from 2021-09-26 23-35-35

只需要再次找到出错的Makefile位置即可

cd kmc
vim makefile

0

没有报错!已经正常安装了

试一下看看,成功了!

QQ图片20210926234831

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

codeqb

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值