赞
踩
PHYLOCOM 是一个用于处理生态和谱系数据的软件,用命令行控制,可以计算多种谱系或群落结构及表型数据,测定性状的保守性及性状间的关联性。软件从github上下载源码压缩包Source code (zip)到集群目录后,按照软件说明文件,解压后使用make命令编译源文件应该是能够正常使用的。
检查当前系统默认的gcc版本信息如下
$which gcc
/share/app/gcc-7.4.0/bin/gcc ### 系统管理员安装的gcc软件位置
$gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/share/app/gcc-7.4.0/libexec/gcc/x86_64-pc-linux-gnu/7.4.0/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: ../configure --prefix=/share/app/gcc-7.4.0
Thread model: posix
gcc version 7.4.0 (GCC)
当前系统默认使用的是集群管理员安装的4.8.5 版本的gcc 编译器。在该编译环境下,尝试对PHYLOCOM的源码进行编译出现
异常
\color {red} {\small 异常}
异常:库文件缺失
这个异常其实只需要重新下载缺失的库文件" libmpc.so.2",安装更新链接其实就能够解决。但是问题是集群不是自己管理的,自己作为普通用户对管理员安装的软件只有使用权限,不能通过yum
命令管理系统上的包。
$make
gcc -Wall -g -O1 -c -o main.o main.c
/share/app/gcc-7.4.0/libexec/gcc/x86_64-pc-linux-gnu/7.4.0/cc1: error while loading shared libraries: libmpc.so.2: cannot open shared object file: No such file or directory
make: *** [main.o] Error 1
$$
总体解决方案
\color {red} {\large {总体解决方案}}
总体解决方案:既然自己只有管理自己创建的目录的权限,所以如果要快捷创建指定版本的GUN编译环境,可以选择在自己的Annaconda环境里进行部署。 推荐使用Conda Forge
编译器包或其子包 cxx-compiler
来为自己的子环境系统获取 C++ 编译器,cxx-compiler
的一个优势是它可以跨平台工作,它可以识别为不同的系统并安装配套的的C++编译器,cxx-compiler 将在 Linux 上安装 g++,在 OSX 上安装 clang++,在 Windows 上安装 vc。
在conda中新建一个新的环境CC_base来安装GUN编译器套件,安装最新版的cxx-compiler
配置最新的C编译软件
$conda create -n CC_base -y
$conda activate CC_base
$conda install -c conda-forge cxx-compiler
$which gcc
/***/Minconda/envs/CC_base/bin/gcc
$gcc -v ### conda环境内安装了 10.3.0 版本的gcc
Reading specs from /***/Minconda/envs/CC_base/bin/../lib/gcc/x86_64-conda-linux-gnu/10.3.0/specs
could not find specs file conda.specs
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/***/Minconda/envs/CC_base/bin/../libexec/gcc/x86_64-conda-linux-gnu/10.3.0/lto-wrapper
Target: x86_64-conda-linux-gnu
Configured with: ../configure --prefix=/home/conda/feedstock_root/build_artifacts/gcc_compilers_1650668905383/_h_env_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placeho --with-slibdir=/home/conda/feedstock_root/build_artifacts/gcc_compilers_1650668905383/_h_env_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placeho/lib --libdir=/home/conda/feedstock_root/build_artifacts/gcc_compilers_1650668905383/_h_env_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placeho/lib --mandir=/home/conda/feedstock_root/build_artifacts/gcc_compilers_1650668905383/_h_env_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placeho/man --build=x86_64-conda-linux-gnu --host=x86_64-conda-linux-gnu --target=x86_64-conda-linux-gnu --enable-default-pie --enable-languages=c,c++,fortran,objc,obj-c++ --enable-__cxa_atexit --disable-libmudflap --enable-libgomp --disable-libssp --enable-libquadmath --enable-libquadmath-support --enable-libsanitizer --enable-lto --enable-threads=posix --enable-target-optspace --enable-plugin --enable-gold --disable-nls --disable-bootstrap --disable-multilib --enable-long-long --with-sysroot=/home/conda/feedstock_root/build_artifacts/gcc_compilers_1650668905383/_h_env_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placeho/x86_64-conda-linux-gnu/sysroot --with-build-sysroot=/home/conda/feedstock_root/build_artifacts/gcc_compilers_1650668905383/_build_env/x86_64-conda-linux-gnu/sysroot --with-gxx-include-dir=/home/conda/feedstock_root/build_artifacts/gcc_compilers_1650668905383/_h_env_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placeho/x86_64-conda-linux-gnu/include/c++/10.3.0 --with-pkgversion='conda-forge gcc 10.3.0-16' --with-bugurl=https://github.com/conda-forge/ctng-compilers-feedstock/issues/new/choose
Thread model: posix
Supported LTO compression algorithms: zlib
gcc version 10.3.0 (conda-forge gcc 10.3.0-16)
安装完成后,再次进入PHYLOCOM的源码文件目录,尝试编译,结果再次遇到错误:
错误意思
\color {red}{\small {错误意思}}
错误意思是函数声明的头文件phylocom.h
的很多全局变量出现了多重定义。
/***/Minconda/envs/CC_base/bin/../lib/gcc/x86_64-conda-linux-gnu/10.3.0/../../../../x86_64-conda-linux-gnu/bin/ld:
comtrait.o:~/test/phylocom-4.2/src/phylocom.h:230:
multiple definition of `SWAPMETHOD';
main.o:~/test/phylocom-4.2/src/phylocom.h:230: : first defined here
编译报错的源码:
认证查阅了一些资料后,认识到原来是新安装的编译器的版本问题,这篇GCC更新说明文档 Porting to GCC 10 - GNU Project 提示说GCC 10 发行版在许多方面与以前的 GCC 发行版不同,其中一些旧行为已被有意更改以支持新标准,所以用 GCC 10 编译的时候可能会导致问题。导致异常的是GCC 10默认使用 -fno-common代替之前的-fno-plt参数(目前来说,这个参数具体作用还不知道,没学过C语言),现在GCC 10 中要求头文件声明全局变量的时候务必添加extern
关键字,类似extern int y;
这样进行声明。 所以,解决办法这个错误的办法要么就是修改头文件phylocom.h,给这些出现多重定义的变量添加上extern
关键字,要么使用旧版本的GCC编译器。我选择后者,直接安装低一级版本的GCC 9来尝试解决错误。
所以在当前环境下用conda重新安装1.2.0 版本的cxx-compiler
,这个这个版的cxx-compiler
包含了GCC 9。
conda install -c conda-forge cxx-compiler=1.2.0 -y
↓ ↓ ↓ \downarrow \downarrow \downarrow ↓↓↓ 安装完成GCC 版本信息
$gcc -v
Reading specs from /***/Minconda/envs/CC_base-9.4.0/bin/../lib/gcc/x86_64-conda-linux-gnu/9.4.0/specs
could not find specs file conda.specs
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/***/Minconda/envs/CC_base-9.4.0/bin/../libexec/gcc/x86_64-conda-linux-gnu/9.4.0/lto-wrapper
Target: x86_64-conda-linux-gnu
Configured with: ../configure --prefix=/home/conda/feedstock_root/build_artifacts/gcc_compilers_1650668900000/_h_env_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placeho --with-slibdir=/home/conda/feedstock_root/build_artifacts/gcc_compilers_1650668900000/_h_env_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placeho/lib --libdir=/home/conda/feedstock_root/build_artifacts/gcc_compilers_1650668900000/_h_env_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placeho/lib --mandir=/home/conda/feedstock_root/build_artifacts/gcc_compilers_1650668900000/_h_env_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placeho/man --build=x86_64-conda-linux-gnu --host=x86_64-conda-linux-gnu --target=x86_64-conda-linux-gnu --enable-default-pie --enable-languages=c,c++,fortran,objc,obj-c++ --enable-__cxa_atexit --disable-libmudflap --enable-libgomp --disable-libssp --enable-libquadmath --enable-libquadmath-support --enable-libsanitizer --enable-lto --enable-threads=posix --enable-target-optspace --enable-plugin --enable-gold --disable-nls --disable-bootstrap --disable-multilib --enable-long-long --with-sysroot=/home/conda/feedstock_root/build_artifacts/gcc_compilers_1650668900000/_h_env_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placeho/x86_64-conda-linux-gnu/sysroot --with-build-sysroot=/home/conda/feedstock_root/build_artifacts/gcc_compilers_1650668900000/_build_env/x86_64-conda-linux-gnu/sysroot --with-gxx-include-dir=/home/conda/feedstock_root/build_artifacts/gcc_compilers_1650668900000/_h_env_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placeho/x86_64-conda-linux-gnu/include/c++/9.4.0 --with-pkgversion='conda-forge gcc 9.4.0-16' --with-bugurl=https://github.com/conda-forge/ctng-compilers-feedstock/issues/new/choose
Thread model: posix
gcc version 9.4.0 (conda-forge gcc 9.4.0-16)
可能是由于conda环境中GCC高级版本回退到低级版本的过程中部分gcc库没有成功回退,导致共享库libgcc_s.so
缺失 引发异常
/***/Minconda/envs/CC_base/bin/../lib/gcc/x86_64-conda-linux-gnu/9.4.0/../../../../x86_64-conda-linux-gnu/bin/ld: cannot find -lgcc_s
collect2: error: ld returned 1 exit status
make: *** [phylocom] Error 1
这个问题可以通过conda安装conda-forge 发布的 libgcc
进行修补,具体需要注意libgcc
的版本要与当前GCC 版本适配,这里选择安装5.2.0版的libgcc。
$conda search libgcc
Loading channels: done
# Name Version Build Channel
libgcc 4.8.4 1 conda-forge
libgcc 4.8.4 1 anaconda/pkgs/free
libgcc 4.8.4 1 anaconda/pkgs/free
libgcc 4.8.5 1 anaconda/pkgs/free
libgcc 4.8.5 1 anaconda/pkgs/free
libgcc 4.8.5 2 conda-forge
libgcc 4.8.5 2 anaconda/pkgs/free
libgcc 4.8.5 2 anaconda/pkgs/free
libgcc 5.2.0 0 conda-forge
libgcc 5.2.0 0 anaconda/pkgs/free
libgcc 5.2.0 0 anaconda/pkgs/free
libgcc 7.2.0 h69d50b8_2 conda-forge
libgcc 7.2.0 h69d50b8_2 pkgs/main
$conda install -c conda-forge libgcc=5.2.0 -y ## 安装libgcc
最后,可以把软件路径添加到自己自己HOME目录下的用户配置文件的内的PATH
变量以方便调用:
echo "export PATH=\"${PWD}:\"\${PATH}" >> ~/.bashrc
总结,这次的软件编译安装过程,促使自己学会了在conda子环境下配置自己的GUN编译器,如果缺少C语言库的话,也能通过conda命令进行快捷安装,从而适应不同情况的软件编译安装需求。
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。